vppapigen: add support for empty options
Type: improvement Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I59323447bee7bb4f0563251a5df80cbefb9bd89e Signed-off-by: Ole Troan <ot@cisco.com>
This commit is contained in:

committed by
Andrew Yourtchenko

parent
710fe10462
commit
68ebcd50bf
@ -59,7 +59,7 @@ cat >crccheck.api <<EOL
|
||||
option version="1.0.0";
|
||||
autoreply define crccheck
|
||||
{
|
||||
option deprecated="v20.11";
|
||||
option deprecated;
|
||||
bool foo;
|
||||
};
|
||||
EOL
|
||||
|
@ -124,6 +124,16 @@ class TestDefine(unittest.TestCase):
|
||||
with self.assertRaises(ParseError):
|
||||
self.parser.parse_string(test_string)
|
||||
|
||||
def test_options(self):
|
||||
test_string = '''
|
||||
define foo { option deprecated; u8 foo; };
|
||||
define foo_reply {u32 context; i32 retval; };
|
||||
'''
|
||||
r = self.parser.parse_string(test_string)
|
||||
self.assertIsNotNone(r)
|
||||
s = self.parser.process(r)
|
||||
self.assertIsNotNone(s)
|
||||
|
||||
|
||||
class TestService(unittest.TestCase):
|
||||
@classmethod
|
||||
|
@ -350,7 +350,7 @@ class Import():
|
||||
|
||||
|
||||
class Option():
|
||||
def __init__(self, option, value):
|
||||
def __init__(self, option, value=None):
|
||||
self.type = 'Option'
|
||||
self.option = option
|
||||
self.value = value
|
||||
@ -686,8 +686,12 @@ class VPPAPIParser(object):
|
||||
p[0] = Array(p[1], p[2], p[4])
|
||||
|
||||
def p_option(self, p):
|
||||
'''option : OPTION ID '=' assignee ';' '''
|
||||
p[0] = Option(p[2], p[4])
|
||||
'''option : OPTION ID '=' assignee ';'
|
||||
| OPTION ID ';' '''
|
||||
if len(p) == 4:
|
||||
p[0] = Option(p[2])
|
||||
else:
|
||||
p[0] = Option(p[2], p[4])
|
||||
|
||||
def p_assignee(self, p):
|
||||
'''assignee : NUM
|
||||
|
Reference in New Issue
Block a user