Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: mojo/public/tools/bindings/pylib/mojom/parse/parser.py

Issue 365993006: Mojo: bindings generator: Add AST types for attributes and attribute lists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/pylib/mojom/parse/parser.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/parser.py b/mojo/public/tools/bindings/pylib/mojom/parse/parser.py
index 317acc0ea5629fad7d63b1242e57dca3d1167e97..60b78e7bc3f67de9943877ee1ed200dad7002326 100644
--- a/mojo/public/tools/bindings/pylib/mojom/parse/parser.py
+++ b/mojo/public/tools/bindings/pylib/mojom/parse/parser.py
@@ -129,19 +129,27 @@ class Parser(object):
if len(p) > 3:
p[0] = p[2]
- def p_attribute_list(self, p):
- """attribute_list : attribute
- | attribute COMMA attribute_list
- | """
- if len(p) == 2:
- p[0] = _ListFromConcat(p[1])
- elif len(p) > 3:
- p[0] = _ListFromConcat(p[1], p[3])
+ def p_attribute_list_1(self, p):
+ """attribute_list : """
+ p[0] = ast.AttributeList()
+
+ def p_attribute_list_2(self, p):
+ """attribute_list : nonempty_attribute_list"""
+ p[0] = p[1]
+
+ def p_nonempty_attribute_list_1(self, p):
+ """nonempty_attribute_list : attribute"""
+ p[0] = ast.AttributeList(p[1])
+
+ def p_nonempty_attribute_list_2(self, p):
+ """nonempty_attribute_list : nonempty_attribute_list COMMA attribute"""
+ p[0] = p[1]
+ p[0].Append(p[3])
def p_attribute(self, p):
"""attribute : NAME EQUALS evaled_literal
| NAME EQUALS NAME"""
- p[0] = ('ATTRIBUTE', p[1], p[3])
+ p[0] = ast.Attribute(p[1], p[3], filename=self.filename, lineno=p.lineno(1))
def p_evaled_literal(self, p):
"""evaled_literal : literal"""
@@ -213,7 +221,7 @@ class Parser(object):
def p_parameter(self, p):
"""parameter : typename NAME ordinal"""
p[0] = ast.Parameter(p[1], p[2], p[3],
- filename=self.filename, lineno=p.lineno(1))
+ filename=self.filename, lineno=p.lineno(2))
def p_typename(self, p):
"""typename : basictypename
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/ast.py ('k') | mojo/public/tools/bindings/pylib/mojom/parse/translate.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698