Commit 42c686dd authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

IDL parser: Make IDL parser to support more keywords

In general, IDL prohibits to use keywords as identifiers.
But the spec defines some places; arguments, operation names,
and attribute names.

This CL makes our IDL parser to be more consistent with
current spec, and also updates few IDL files that can be
consistent with their specs with this change.


Bug: 839389
Change-Id: I60802ae211c3dffd4e9f3a76ad5dd2a3910791a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855623Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705131}
parent e712abd4
......@@ -6,7 +6,7 @@
[Exposed=Window]
interface CustomElementRegistry {
[CallWith=ScriptState, CEReactions, CustomElementCallbacks, RaisesException, MeasureAs=CustomElementRegistryDefine] void define(DOMString name, CustomElementConstructor _constructor, optional ElementDefinitionOptions options);
[CallWith=ScriptState, CEReactions, CustomElementCallbacks, RaisesException, MeasureAs=CustomElementRegistryDefine] void define(DOMString name, CustomElementConstructor constructor, optional ElementDefinitionOptions options);
any get(DOMString name);
[CallWith=ScriptState,RaisesException] Promise<void> whenDefined(DOMString name);
[CEReactions] void upgrade(Node root);
......
......@@ -41,5 +41,5 @@
optional boolean lowerOpen = false,
optional boolean upperOpen = false);
[CallWith=ScriptState, RaisesException] boolean _includes(any key);
[CallWith=ScriptState, RaisesException] boolean includes(any key);
};
......@@ -274,14 +274,20 @@ class IDLParser(object):
| ATTRIBUTE
| CALLBACK
| CONST
| CONSTRUCTOR
| DELETER
| DICTIONARY
| ENUM
| GETTER
| INCLUDES
| INHERIT
| INTERFACE
| ITERABLE
| MAPLIKE
| NAMESPACE
| PARTIAL
| REQUIRED
| SETLIKE
| SETTER
| STATIC
| STRINGIFIER
......@@ -555,13 +561,22 @@ class IDLParser(object):
p[0] = self.BuildNamed('Operation', p, 1, arguments)
def p_OptionalOperationName(self, p):
"""OptionalOperationName : identifier
"""OptionalOperationName : OperationName
|"""
if len(p) > 1:
p[0] = p[1]
else:
p[0] = ''
def p_OperationName(self, p):
"""OperationName : OperationNameKeyword
| identifier"""
p[0] = p[1]
def p_OperationNameKeyword(self, p):
"""OperationNameKeyword : INCLUDES"""
p[0] = p[1]
def p_ArgumentList(self, p):
"""ArgumentList : Argument Arguments
|"""
......
......@@ -151,6 +151,33 @@ interface MyIFaceWrongRecordKeyType {
void foo(record<int, ByteString> arg);
};
/** TREE
*Interface(IFaceAllowedKeywords)
* Attribute(async)
* Type()
* PrimitiveType(long)
* Operation(includes)
* Arguments()
* Argument(async)
* Type()
* PrimitiveType(long)
* Argument(constructor)
* Type()
* PrimitiveType(long)
* Type()
* PrimitiveType(void)
* Attribute(constructor)
* Type()
* PrimitiveType(long)
* Error(Unexpected constructor.)
*/
interface IFaceAllowedKeywords {
attribute long async;
void includes(long async, long constructor);
attribute long _constructor;
attribute long constructor;
};
/** TREE
*Interface(MyIfaceDefalutValue)
* Operation(foo)
......@@ -667,19 +694,3 @@ interface MyIFaceArgumentWithAnnotatedType2 {
* REFERENCE: Bar
*/
Foo includes Bar;
/** TREE
*Interface(IFaceWithKeyword)
* Operation(includes)
* Arguments()
* Argument(val)
* Type()
* StringType(DOMString)
* Type()
* PrimitiveType(void)
*/
interface IFaceWithKeyword {
// '_' prefix needs to be removed in tokenization.
// https://heycam.github.io/webidl/#idl-names
void _includes(DOMString val);
};
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