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

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

Issue 398553002: Mojo: Mojom: Add AST types for struct and struct body. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 3a3bf31e0cb11a494e00ec965b91405d47922c77..5f4a10070c32ef4ddcccaeff1856de5be2bd0f21 100644
--- a/mojo/public/tools/bindings/pylib/mojom/parse/parser.py
+++ b/mojo/public/tools/bindings/pylib/mojom/parse/parser.py
@@ -169,18 +169,21 @@ class Parser(object):
def p_struct(self, p):
"""struct : attribute_section STRUCT NAME LBRACE struct_body RBRACE SEMI"""
- p[0] = ('STRUCT', p[3], p[1], p[5])
+ p[0] = ast.Struct(p[3], p[1], p[5])
- def p_struct_body(self, p):
- """struct_body : field struct_body
- | enum struct_body
- | const struct_body
- | """
- if len(p) > 1:
- p[0] = _ListFromConcat(p[1], p[2])
+ def p_struct_body_1(self, p):
+ """struct_body : """
+ p[0] = ast.StructBody()
+
+ def p_struct_body_2(self, p):
+ """struct_body : struct_body const
+ | struct_body enum
+ | struct_body struct_field"""
+ p[0] = p[1]
+ p[0].Append(p[2])
- def p_field(self, p):
- """field : typename NAME ordinal default SEMI"""
+ def p_struct_field(self, p):
+ """struct_field : typename NAME ordinal default SEMI"""
p[0] = ast.StructField(p[2], p[3], p[1], p[4])
def p_default_1(self, p):

Powered by Google App Engine
This is Rietveld 408576698