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

Unified Diff: tools/idl_parser/idl_parser.py

Issue 2048613002: Upstream the grammer for union types to idl_parser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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: tools/idl_parser/idl_parser.py
diff --git a/tools/idl_parser/idl_parser.py b/tools/idl_parser/idl_parser.py
index ff787a46346568708f03dd954ce6a6b326dacd0c..e022603da5230f5dfe29dfc404c3007a5e8a34c8 100755
--- a/tools/idl_parser/idl_parser.py
+++ b/tools/idl_parser/idl_parser.py
@@ -870,16 +870,28 @@ class IDLParser(object):
# [75]
def p_UnionType(self, p):
"""UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ')'"""
+ members = ListFromConcat(p[2], p[4], p[5])
+ p[0] = self.BuildProduction('UnionType', p, 1, members)
# [76]
def p_UnionMemberType(self, p):
"""UnionMemberType : NonAnyType
| UnionType TypeSuffix
| ANY '[' ']' TypeSuffix"""
+ if len(p) == 2:
+ p[0] = self.BuildProduction('Type', p, 1, p[1])
+ elif len(p) == 3:
+ p[0] = self.BuildProduction('Type', p, 1, ListFromConcat(p[1], p[2]))
+ else:
+ any_node = ListFromConcat(self.BuildProduction('Any', p, 1), p[4])
+ p[0] = self.BuildProduction('Type', p, 1, any_node)
+
# [77]
def p_UnionMemberTypes(self, p):
"""UnionMemberTypes : OR UnionMemberType UnionMemberTypes
|"""
+ if len(p) > 2:
+ p[0] = ListFromConcat(p[2], p[3])
# [78] Moved BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP to PrimitiveType
# Moving all built-in types into PrimitiveType makes it easier to
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/blink_idl_parser.py ('k') | tools/idl_parser/test_parser/interface_web.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698