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

Unified Diff: tools/idl_parser/idl_parser.py

Issue 2708173002: idl_parser: Add support for the record<K, V> WebIDL type. (Closed)
Patch Set: Created 3 years, 10 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 d7a00aa1b59a302c70da7674e3449040431d2f28..9443ce1c683be7a720967603459719869654df99 100755
--- a/tools/idl_parser/idl_parser.py
+++ b/tools/idl_parser/idl_parser.py
@@ -892,7 +892,8 @@ class IDLParser(object):
| PromiseType Null
| identifier TypeSuffix
| SEQUENCE '<' Type '>' Null
- | FROZENARRAY '<' Type '>' Null"""
+ | FROZENARRAY '<' Type '>' Null
+ | RecordType Null"""
if len(p) == 3:
if type(p[1]) == str:
typeref = self.BuildNamed('Typeref', p, 1)
@@ -917,15 +918,14 @@ class IDLParser(object):
p[0] = p[1]
- # [81] Added BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP
+ # [81] Added StringType, OBJECT, DATE, REGEXP
def p_PrimitiveType(self, p):
"""PrimitiveType : UnsignedIntegerType
| UnrestrictedFloatType
+ | StringType
| BOOLEAN
| BYTE
| OCTET
- | BYTESTRING
- | DOMSTRING
| OBJECT
| DATE
| REGEXP"""
@@ -1076,6 +1076,23 @@ class IDLParser(object):
value = self.BuildNamed('Call', p, 3, args)
p[0] = self.BuildNamed('ExtAttribute', p, 1, value)
+ # [99]
+ def p_StringType(self, p):
+ """StringType : BYTESTRING
+ | DOMSTRING
+ | USVSTRING"""
+ p[0] = self.BuildNamed('StringType', p, 1)
+
+ # [100]
+ def p_RecordType(self, p):
+ """RecordType : RECORD '<' StringType ',' Type '>'"""
+ p[0] = self.BuildProduction('Record', p, 2, ListFromConcat(p[3], p[5]))
+
+ # [100.1] Error recovery for RecordType.
+ def p_RecordTypeError(self, p):
+ """RecordType : RECORD '<' error ',' Type '>'"""
+ p[0] = self.BuildError(p, 'RecordType')
+
#
# Parser Errors
#
@@ -1138,9 +1155,9 @@ class IDLParser(object):
# Production is the set of items sent to a grammar rule resulting in a new
# item being returned.
#
+# cls - The type of item being producted
# p - Is the Yacc production object containing the stack of items
# index - Index into the production of the name for the item being produced.
-# cls - The type of item being producted
# childlist - The children of the new item
def BuildProduction(self, cls, p, index, childlist=None):
try:

Powered by Google App Engine
This is Rietveld 408576698