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

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

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years 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 e5269c7fd5f7fbbb942c699692396419a79c8a4b..4225f0a7f2373e293f385b2ff2384e76ff318229 100644
--- a/mojo/public/tools/bindings/pylib/mojom/parse/parser.py
+++ b/mojo/public/tools/bindings/pylib/mojom/parse/parser.py
@@ -21,7 +21,7 @@ def _GetDirAbove(dirname):
try:
imp.find_module("ply")
except ImportError:
- sys.path.append(os.path.join(_GetDirAbove("mojo"), "third_party"))
+ sys.path.append(os.path.join(_GetDirAbove("public"), "public/third_party"))
from ply import lex
from ply import yacc
@@ -114,6 +114,7 @@ class Parser(object):
def p_definition(self, p):
"""definition : struct
+ | union
| interface
| enum
| const"""
@@ -173,6 +174,23 @@ class Parser(object):
"""struct_field : typename NAME ordinal default SEMI"""
p[0] = ast.StructField(p[2], p[3], p[1], p[4])
+ def p_union(self, p):
+ """union : UNION NAME LBRACE union_body RBRACE SEMI"""
+ p[0] = ast.Union(p[2], p[4])
+
+ def p_union_body_1(self, p):
+ """union_body : """
+ p[0] = ast.UnionBody()
+
+ def p_union_body_2(self, p):
+ """union_body : union_body union_field"""
+ p[0] = p[1]
+ p[1].Append(p[2])
+
+ def p_union_field(self, p):
+ """union_field : typename NAME ordinal SEMI"""
+ p[0] = ast.UnionField(p[2], p[3], p[1])
+
def p_default_1(self, p):
"""default : """
p[0] = None
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/lexer.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