diff options
author | noelallen@chromium.org <noelallen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 18:43:00 +0000 |
---|---|---|
committer | noelallen@chromium.org <noelallen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 18:43:00 +0000 |
commit | 888658d9d077a19b021fd6d40fb08ab2b582e37e (patch) | |
tree | 614db3b61865a5611233fa328f570b1d7aaab18d /tools/idl_parser | |
parent | 6ac6c88c110391acda07fd24590d5b4e5e073d71 (diff) | |
download | chromium_src-888658d9d077a19b021fd6d40fb08ab2b582e37e.zip chromium_src-888658d9d077a19b021fd6d40fb08ab2b582e37e.tar.gz chromium_src-888658d9d077a19b021fd6d40fb08ab2b582e37e.tar.bz2 |
Fix ConstValue productions.
Fix nesting of Attribute(VALUE) = [Attribute(VALUE) + Atribute(TYPE)] when using Literal floats and bools.
Switch to attribute VALUE instead of NAME for Consts.
Dump VALUE and TYPE by default when dumping tree.
Add test for BOOL production in enum.
NOTE: ATM it's legal to assign a bool to an ENUM, however I will change this in a future CL when I specialize int only const values.
BUG=224150
TEST=PRESUBMIT.py
R=nfullagar@chromium.org
Review URL: https://codereview.chromium.org/18274002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209462 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/idl_parser')
-rwxr-xr-x | tools/idl_parser/idl_node.py | 8 | ||||
-rwxr-xr-x | tools/idl_parser/idl_parser.py | 2 | ||||
-rwxr-xr-x | tools/idl_parser/idl_ppapi_parser.py | 11 | ||||
-rw-r--r-- | tools/idl_parser/test_parser/enum_ppapi.idl | 7 |
4 files changed, 17 insertions, 11 deletions
diff --git a/tools/idl_parser/idl_node.py b/tools/idl_parser/idl_node.py index 2e31d9a..83aefa5 100755 --- a/tools/idl_parser/idl_node.py +++ b/tools/idl_parser/idl_node.py @@ -148,13 +148,13 @@ class IDLNode(object): tab = ''.rjust(self.depth * 2) self.out.append(tab + str(node)) if self.props: + proplist = [] for key, value in node.GetProperties().iteritems(): - proplist = [] if key in self.props: proplist.append(tab + ' %s: %s' % (key, str(value))) - if proplist: - self.out.append(tab + ' PROPERTIES') - self.out.extend(proplist) + if proplist: + self.out.append(tab + ' PROPERTIES') + self.out.extend(proplist) if filter_nodes == None: filter_nodes = ['Comment', 'Copyright'] diff --git a/tools/idl_parser/idl_parser.py b/tools/idl_parser/idl_parser.py index 22f7262..f1ec51e 100755 --- a/tools/idl_parser/idl_parser.py +++ b/tools/idl_parser/idl_parser.py @@ -401,7 +401,7 @@ class IDLParser(object): def p_BooleanLiteral(self, p): """BooleanLiteral : TRUE | FALSE""" - value = self.BuildAttribute('NAME', Boolean(p[1] == 'true')) + value = self.BuildAttribute('VALUE', Boolean(p[1] == 'true')) p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'boolean'), value) # [29] diff --git a/tools/idl_parser/idl_ppapi_parser.py b/tools/idl_parser/idl_ppapi_parser.py index 9cfe953..0e5116c 100755 --- a/tools/idl_parser/idl_ppapi_parser.py +++ b/tools/idl_parser/idl_ppapi_parser.py @@ -117,21 +117,20 @@ class IDLPPAPIParser(IDLParser): val = str(p[1]) if len(p) > 2: val = "%s %s %s" % (p[1], p[2], p[3]) - p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'integer'), - self.BuildAttribute('NAME', val)) + self.BuildAttribute('VALUE', val)) def p_ConstValueStr(self, p): """ConstValue : string""" p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'string'), - self.BuildAttribute('NAME', p[1])) + self.BuildAttribute('VALUE', p[1])) + # Boolean & Float Literals area already BuildAttributes def p_ConstValueLiteral(self, p): """ConstValue : FloatLiteral | BooleanLiteral """ p[0] = p[1] - # [21] def p_EnumValueList(self, p): """EnumValueList : EnumValue EnumValues""" @@ -149,7 +148,7 @@ class IDLPPAPIParser(IDLParser): | ExtendedAttributeList identifier '=' ConstValue""" p[0] = self.BuildNamed('EnumItem', p, 2, p[1]) if len(p) > 3: - p[0].AddChildren(self.BuildAttribute('VALUE', p[4])) + p[0].AddChildren(p[4]) def p_PrimitiveType(self, p): """PrimitiveType : IntegerType @@ -229,7 +228,7 @@ def main(argv): ast = IDLNode('AST', '__AST__', 0, 0, nodes) - print '\n'.join(ast.Tree(accept_props=['PROD','VALUE'])) + print '\n'.join(ast.Tree(accept_props=['PROD', 'TYPE', 'VALUE'])) if errors: print '\nFound %d errors.\n' % errors diff --git a/tools/idl_parser/test_parser/enum_ppapi.idl b/tools/idl_parser/test_parser/enum_ppapi.idl index 394e680..1b088b8 100644 --- a/tools/idl_parser/test_parser/enum_ppapi.idl +++ b/tools/idl_parser/test_parser/enum_ppapi.idl @@ -117,3 +117,10 @@ enum MealType3 { other = 012 << 777 }; +/* BUILD Enum(MealType4) */ +enum MealType4 { + /* BUILD EnumItem(rice) */ + rice = true, + /* BUILD EnumItem(noodles) */ + noodles = false +}; |