Commit 6ce2b8e1 authored by yhirano's avatar yhirano Committed by Commit bot

Support Promise<T> syntax in the IDL parser.

The Web IDL spec specifies Promise<T> syntax. This CL makes the IDL parser
recognize the syntax.

BUG=421539

Review URL: https://codereview.chromium.org/653343002

Cr-Commit-Position: refs/heads/master@{#300255}
parent 5f318980
......@@ -94,6 +94,7 @@ class IDLLexer(object):
'optional' : 'OPTIONAL',
'or' : 'OR',
'partial' : 'PARTIAL',
'Promise' : 'PROMISE',
'readonly' : 'READONLY',
'RegExp' : 'REGEXP',
'sequence' : 'SEQUENCE',
......
This diff is collapsed.
......@@ -59,8 +59,8 @@ class IDLPPAPILexer(IDLLexer):
# Remove JS types
self._DelKeywords(['boolean', 'byte', 'ByteString', 'Date', 'DOMString',
'double', 'float', 'long', 'object', 'octet', 'RegExp',
'short', 'unsigned'])
'double', 'float', 'long', 'object', 'octet', 'Promise',
'RegExp', 'short', 'unsigned'])
# If run by itself, attempt to build the lexer
......
......@@ -124,18 +124,15 @@ class IDLPPAPIParser(IDLParser):
"""StructMember : ExtendedAttributeList Type identifier ';'"""
p[0] = self.BuildNamed('Member', p, 3, ListFromConcat(p[1], p[2]))
# [24]
def p_Typedef(self, p):
"""Typedef : TYPEDEF ExtendedAttributeListNoComments Type identifier ';'"""
p[0] = self.BuildNamed('Typedef', p, 4, ListFromConcat(p[2], p[3]))
# [24.1]
def p_TypedefFunc(self, p):
"""Typedef : TYPEDEF ExtendedAttributeListNoComments ReturnType identifier '(' ArgumentList ')' ';'"""
args = self.BuildProduction('Arguments', p, 5, p[6])
p[0] = self.BuildNamed('Callback', p, 4, ListFromConcat(p[2], p[3], args))
# [27]
def p_ConstValue(self, p):
"""ConstValue : integer
| integer LSHIFT integer
......@@ -157,12 +154,10 @@ class IDLPPAPIParser(IDLParser):
| BooleanLiteral """
p[0] = p[1]
# [21]
def p_EnumValueList(self, p):
"""EnumValueList : EnumValue EnumValues"""
p[0] = ListFromConcat(p[1], p[2])
# [22]
def p_EnumValues(self, p):
"""EnumValues : ',' EnumValue EnumValues
|"""
......@@ -176,6 +171,13 @@ class IDLPPAPIParser(IDLParser):
if len(p) > 3:
p[0].AddChildren(p[4])
# Omit PromiseType, as it is a JS type.
def p_NonAnyType(self, p):
"""NonAnyType : PrimitiveType TypeSuffix
| identifier TypeSuffix
| SEQUENCE '<' Type '>' Null"""
IDLParser.p_NonAnyType(self, p)
def p_PrimitiveType(self, p):
"""PrimitiveType : IntegerType
| UnsignedIntegerType
......@@ -200,13 +202,11 @@ class IDLPPAPIParser(IDLParser):
| PP_FILEHANDLE"""
p[0] = p[1]
# [66]
def p_FloatType(self, p):
"""FloatType : FLOAT_T
| DOUBLE_T"""
p[0] = p[1]
# [67]
def p_UnsignedIntegerType(self, p):
"""UnsignedIntegerType : UINT8_T
| UINT16_T
......@@ -215,7 +215,6 @@ class IDLPPAPIParser(IDLParser):
p[0] = p[1]
# [68]
def p_IntegerType(self, p):
"""IntegerType : CHAR
| INT8_T
......@@ -237,6 +236,10 @@ class IDLPPAPIParser(IDLParser):
""" """
pass
def p_PromiseType(self, p):
""" """
pass
# We only support:
# [ identifier ]
# [ identifier ( ArgumentList )]
......@@ -272,7 +275,6 @@ class IDLPPAPIParser(IDLParser):
if len(p) > 1:
p[0] = p[1]
# [76]
def p_ExtendedAttributeIdentConst(self, p):
"""ExtendedAttributeIdentConst : identifier '=' ConstValue"""
p[0] = self.BuildNamed('ExtAttribute', p, 1, p[3])
......
......@@ -181,3 +181,37 @@ interface MyIFaceStringifiers {
interface MyExtendedAttributeInterface {
[Attr, MethodIdentList=(Foo, Bar)] void method();
};
/* TREE
*Interface(MyIfacePromise)
* Operation(method1)
* Arguments()
* Type()
* Promise(Promise)
* Type()
* PrimitiveType(void)
* Operation(method2)
* Arguments()
* Type()
* Promise(Promise)
* Type()
* PrimitiveType(long)
* Operation(method3)
* Arguments()
* Type()
* Promise(Promise)
* Type()
* Any()
* Operation(method4)
* Arguments()
* Type()
* Promise(Promise)
* Type()
* Any()
*/
interface MyIfacePromise {
Promise<void> method1();
Promise<long> method2();
Promise<any> method3();
Promise method4();
};
......@@ -42,6 +42,9 @@ symatics should exist. This is an exact match.
* ExtAttribute(fake_attribute)
* Type()
* PrimitiveType(str_t)
* Member(z)
* Type()
* Typeref(Promise)
* ExtAttributes()
* ExtAttribute(union)
*/
......@@ -49,4 +52,5 @@ symatics should exist. This is an exact match.
uint32_t x;
uint64_t y;
[fake_attribute] str_t string;
Promise z;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment