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):
'attribute' : 'ATTRIBUTE',
'boolean' : 'BOOLEAN',
'byte' : 'BYTE',
'ByteString' : 'BYTESTRING',
'callback' : 'CALLBACK',
'const' : 'CONST',
'creator' : 'CREATOR',
......@@ -94,7 +95,9 @@ class IDLLexer(object):
'or' : 'OR',
'partial' : 'PARTIAL',
'readonly' : 'READONLY',
'RegExp' : 'REGEXP',
'sequence' : 'SEQUENCE',
'serializer' : 'SERIALIZER',
'setter': 'SETTER',
'short' : 'SHORT',
'static' : 'STATIC',
......
......@@ -201,7 +201,7 @@ class IDLNode(object):
child._parent = self
self._children.append(child)
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):
self._AddKeywords(['mem_t', 'str_t', 'cstr_t', 'interface_t'])
# Remove JS types
self._DelKeywords(['boolean', 'byte', 'Date', 'DOMString', 'double',
'float', 'long', 'object', 'octet', 'short', 'unsigned'])
self._DelKeywords(['boolean', 'byte', 'ByteString', 'Date', 'DOMString',
'double', 'float', 'long', 'object', 'octet', 'RegExp',
'short', 'unsigned'])
# If run by itself, attempt to build the lexer
......
......@@ -12,7 +12,7 @@
# on WebIDL.
#
# 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:
# http://www.dabeaz.com/ply/
#
......@@ -50,7 +50,7 @@ class IDLPPAPIParser(IDLParser):
#
#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]
def p_Definitions(self, p):
......
ANY any
ATTRIBUTE attribute
BOOLEAN boolean
BYTESTRING ByteString
BYTE byte
CALLBACK callback
CONST const
......@@ -26,6 +27,8 @@ OPTIONAL optional
OR or
PARTIAL partial
READONLY readonly
REGEXP RegExp
SERIALIZER serializer
SETTER setter
SHORT short
STATIC static
......
......@@ -67,6 +67,18 @@ enum MealType2 {
"other"
};
/* TREE
*Enum(TrailingComma)
* EnumItem(rice)
* EnumItem(noodles)
* EnumItem(other)
*/
enum TrailingComma {
"rice",
"noodles",
"other",
};
/* BUILD Error(Unexpected string "noodles" after string "rice".) */
/* ERROR Unexpected string "noodles" after string "rice". */
enum MissingComma {
......@@ -75,14 +87,6 @@ enum MissingComma {
"other"
};
/* BUILD Error(Trailing comma in block.) */
/* ERROR Trailing comma in block. */
enum TrailingComma {
"rice",
"noodles",
"other",
};
/* BUILD Error(Unexpected "," after ",".) */
/* ERROR Unexpected "," after ",". */
enum ExtraComma {
......
......@@ -76,13 +76,23 @@ interface MyIFaceBig {
* Attribute(readOnlyString)
* Type()
* PrimitiveType(DOMString)
* Attribute(staticString)
* Type()
* PrimitiveType(DOMString)
* Operation(myFunction)
* Arguments()
* Argument(myLong)
* Type()
* PrimitiveType(long long)
* Type()
* PrimitiveType(void)
* Operation(staticFunction)
* Arguments()
* Argument(myLong)
* Type()
* PrimitiveType(long long)
* Type()
* PrimitiveType(void)
*/
interface MyIFaceBig2 {
const DOMString? nullValue = null;
......@@ -90,35 +100,37 @@ interface MyIFaceBig2 {
const long long longValue2 = 123;
attribute DOMString myString;
readonly attribute DOMString readOnlyString;
static attribute DOMString staticString;
void myFunction(long long myLong);
static void staticFunction(long long myLong);
};
/* TREE
*Interface(MyIFaceSpecials)
* Operation(set)
* Type()
* PrimitiveType(void)
* Arguments()
* Argument(property)
* Type()
* PrimitiveType(DOMString)
* Operation(_unnamed_)
* Type()
* PrimitiveType(double)
* PrimitiveType(void)
* Operation(_unnamed_)
* Arguments()
* Argument(property)
* Type()
* PrimitiveType(DOMString)
* Operation(GetFiveSix)
* Type()
* PrimitiveType(long long)
* Array(5)
* Array(6)
* PrimitiveType(double)
* Operation(GetFiveSix)
* Arguments()
* Argument(arg)
* Type()
* Typeref(SomeType)
* Type()
* PrimitiveType(long long)
* Array(5)
* Array(6)
*/
interface MyIFaceSpecials {
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