Commit 5885b696 authored by jl@opera.com's avatar jl@opera.com

IDL parser: align with current Web IDL specification

Mostly renumbered and restructured grammar productions.  Notable changes:

- add support for static attributes via StaticMember
- add support for built-in types ByteString and RegExp
- allow trailing comma in enum declarations

Depends on:
IDL parser: drop AttributeOrOperation and StaticAttribute overrides
https://codereview.chromium.org/336733002/
...or else breaks Blink compile.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278365 0039d316-1c4b-4281-b951-d872f2087c98
parent cb7f3e39
...@@ -67,6 +67,7 @@ class IDLLexer(object): ...@@ -67,6 +67,7 @@ class IDLLexer(object):
'attribute' : 'ATTRIBUTE', 'attribute' : 'ATTRIBUTE',
'boolean' : 'BOOLEAN', 'boolean' : 'BOOLEAN',
'byte' : 'BYTE', 'byte' : 'BYTE',
'ByteString' : 'BYTESTRING',
'callback' : 'CALLBACK', 'callback' : 'CALLBACK',
'const' : 'CONST', 'const' : 'CONST',
'creator' : 'CREATOR', 'creator' : 'CREATOR',
...@@ -94,7 +95,9 @@ class IDLLexer(object): ...@@ -94,7 +95,9 @@ class IDLLexer(object):
'or' : 'OR', 'or' : 'OR',
'partial' : 'PARTIAL', 'partial' : 'PARTIAL',
'readonly' : 'READONLY', 'readonly' : 'READONLY',
'RegExp' : 'REGEXP',
'sequence' : 'SEQUENCE', 'sequence' : 'SEQUENCE',
'serializer' : 'SERIALIZER',
'setter': 'SETTER', 'setter': 'SETTER',
'short' : 'SHORT', 'short' : 'SHORT',
'static' : 'STATIC', 'static' : 'STATIC',
......
...@@ -201,7 +201,7 @@ class IDLNode(object): ...@@ -201,7 +201,7 @@ class IDLNode(object):
child._parent = self child._parent = self
self._children.append(child) self._children.append(child)
continue continue
raise RuntimeError('Adding child of type .\n' % type(child).__name__) raise RuntimeError('Adding child of type %s.\n' % type(child).__name__)
# #
......
This diff is collapsed.
...@@ -58,8 +58,9 @@ class IDLPPAPILexer(IDLLexer): ...@@ -58,8 +58,9 @@ class IDLPPAPILexer(IDLLexer):
self._AddKeywords(['mem_t', 'str_t', 'cstr_t', 'interface_t']) self._AddKeywords(['mem_t', 'str_t', 'cstr_t', 'interface_t'])
# Remove JS types # Remove JS types
self._DelKeywords(['boolean', 'byte', 'Date', 'DOMString', 'double', self._DelKeywords(['boolean', 'byte', 'ByteString', 'Date', 'DOMString',
'float', 'long', 'object', 'octet', 'short', 'unsigned']) 'double', 'float', 'long', 'object', 'octet', 'RegExp',
'short', 'unsigned'])
# If run by itself, attempt to build the lexer # If run by itself, attempt to build the lexer
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# on WebIDL. # on WebIDL.
# #
# WebIDL, and WebIDL grammar can be found at: # WebIDL, and WebIDL grammar can be found at:
# http://dev.w3.org/2006/webapi/WebIDL/ # http://heycam.github.io/webidl/
# PLY can be found at: # PLY can be found at:
# http://www.dabeaz.com/ply/ # http://www.dabeaz.com/ply/
# #
...@@ -50,7 +50,7 @@ class IDLPPAPIParser(IDLParser): ...@@ -50,7 +50,7 @@ class IDLPPAPIParser(IDLParser):
# #
#The parser is based on the WebIDL standard. See: #The parser is based on the WebIDL standard. See:
# http://www.w3.org/TR/WebIDL/#idl-grammar # http://heycam.github.io/webidl/#idl-grammar
# #
# [1] # [1]
def p_Definitions(self, p): def p_Definitions(self, p):
......
ANY any ANY any
ATTRIBUTE attribute ATTRIBUTE attribute
BOOLEAN boolean BOOLEAN boolean
BYTESTRING ByteString
BYTE byte BYTE byte
CALLBACK callback CALLBACK callback
CONST const CONST const
...@@ -26,6 +27,8 @@ OPTIONAL optional ...@@ -26,6 +27,8 @@ OPTIONAL optional
OR or OR or
PARTIAL partial PARTIAL partial
READONLY readonly READONLY readonly
REGEXP RegExp
SERIALIZER serializer
SETTER setter SETTER setter
SHORT short SHORT short
STATIC static STATIC static
......
...@@ -67,6 +67,18 @@ enum MealType2 { ...@@ -67,6 +67,18 @@ enum MealType2 {
"other" "other"
}; };
/* TREE
*Enum(TrailingComma)
* EnumItem(rice)
* EnumItem(noodles)
* EnumItem(other)
*/
enum TrailingComma {
"rice",
"noodles",
"other",
};
/* BUILD Error(Unexpected string "noodles" after string "rice".) */ /* BUILD Error(Unexpected string "noodles" after string "rice".) */
/* ERROR Unexpected string "noodles" after string "rice". */ /* ERROR Unexpected string "noodles" after string "rice". */
enum MissingComma { enum MissingComma {
...@@ -75,14 +87,6 @@ enum MissingComma { ...@@ -75,14 +87,6 @@ enum MissingComma {
"other" "other"
}; };
/* BUILD Error(Trailing comma in block.) */
/* ERROR Trailing comma in block. */
enum TrailingComma {
"rice",
"noodles",
"other",
};
/* BUILD Error(Unexpected "," after ",".) */ /* BUILD Error(Unexpected "," after ",".) */
/* ERROR Unexpected "," after ",". */ /* ERROR Unexpected "," after ",". */
enum ExtraComma { enum ExtraComma {
......
...@@ -76,13 +76,23 @@ interface MyIFaceBig { ...@@ -76,13 +76,23 @@ interface MyIFaceBig {
* Attribute(readOnlyString) * Attribute(readOnlyString)
* Type() * Type()
* PrimitiveType(DOMString) * PrimitiveType(DOMString)
* Attribute(staticString)
* Type()
* PrimitiveType(DOMString)
* Operation(myFunction) * Operation(myFunction)
* Arguments()
* Argument(myLong)
* Type()
* PrimitiveType(long long)
* Type() * Type()
* PrimitiveType(void) * PrimitiveType(void)
* Operation(staticFunction)
* Arguments() * Arguments()
* Argument(myLong) * Argument(myLong)
* Type() * Type()
* PrimitiveType(long long) * PrimitiveType(long long)
* Type()
* PrimitiveType(void)
*/ */
interface MyIFaceBig2 { interface MyIFaceBig2 {
const DOMString? nullValue = null; const DOMString? nullValue = null;
...@@ -90,35 +100,37 @@ interface MyIFaceBig2 { ...@@ -90,35 +100,37 @@ interface MyIFaceBig2 {
const long long longValue2 = 123; const long long longValue2 = 123;
attribute DOMString myString; attribute DOMString myString;
readonly attribute DOMString readOnlyString; readonly attribute DOMString readOnlyString;
static attribute DOMString staticString;
void myFunction(long long myLong); void myFunction(long long myLong);
static void staticFunction(long long myLong);
}; };
/* TREE /* TREE
*Interface(MyIFaceSpecials) *Interface(MyIFaceSpecials)
* Operation(set) * Operation(set)
* Type()
* PrimitiveType(void)
* Arguments() * Arguments()
* Argument(property) * Argument(property)
* Type() * Type()
* PrimitiveType(DOMString) * PrimitiveType(DOMString)
* Operation(_unnamed_)
* Type() * Type()
* PrimitiveType(double) * PrimitiveType(void)
* Operation(_unnamed_)
* Arguments() * Arguments()
* Argument(property) * Argument(property)
* Type() * Type()
* PrimitiveType(DOMString) * PrimitiveType(DOMString)
* Operation(GetFiveSix)
* Type() * Type()
* PrimitiveType(long long) * PrimitiveType(double)
* Array(5) * Operation(GetFiveSix)
* Array(6)
* Arguments() * Arguments()
* Argument(arg) * Argument(arg)
* Type() * Type()
* Typeref(SomeType) * Typeref(SomeType)
* Type()
* PrimitiveType(long long)
* Array(5)
* Array(6)
*/ */
interface MyIFaceSpecials { interface MyIFaceSpecials {
setter creator void set(DOMString property); setter creator void set(DOMString property);
......
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