lib/webidl/parser/idl.treetop in webidl-0.1.7 vs lib/webidl/parser/idl.treetop in webidl-0.1.8
- old
+ new
@@ -1,5 +1,6 @@
+# -*- coding: utf-8 -*-
module WebIDL
module Parser
# http://dev.w3.org/2006/webapi/WebIDL/#idl-grammar
grammar IDL
@@ -16,15 +17,15 @@
/ Exception
/ Enum
/ TypeDef
/ ImplementsStatement
end
-
+
rule CallbackOrInterface
- "callback" ws obj:CallbackRestOrInterface { def build(parent) obj.build(parent) end }
+ "callback" ws obj:CallbackRestOrInterface { def build(parent) obj.build(parent) end }
end
-
+
rule CallbackRestOrInterface
CallbackRest / Interface
end
rule Interface
@@ -91,11 +92,11 @@
# extract to a generic Members syntax node?
rule ExceptionMembers
(eal:ExtendedAttributeList ws member:ExceptionMember ws members:ExceptionMembers ws <ParseTree::InterfaceMembers>)?
end
-
+
rule CallbackRest
name:identifier ws "=" ws return_type:ReturnType ws "(" ws args:ArgumentList ")" ws ";" <ParseTree::Callback>
end
rule TypeDef
@@ -289,10 +290,11 @@
rule ExtendedAttribute
ExtendedAttributeNamedArgList
/ ExtendedAttributeIdent
/ ExtendedAttributeScopedName
/ ExtendedAttributeArgList
+ / ExtendedAttributeIdentList
/ ExtendedAttributeNoArg
end
rule ExtendedAttributeNoArg
identifier {
@@ -316,11 +318,25 @@
rule ExtendedAttributeNamedArgList
key:identifier "=" value:(name:identifier "(" ws args:ArgumentList ws ")" <ParseTree::ExtendedAttributeArgList>) <ParseTree::ExtendedAttributeNamedArgList>
end
+ rule ExtendedAttributeIdentList
+ key:identifier "=" "(" list:IdentifierList ")" <ParseTree::ExtendedAttributeIdentList>
+ end
+ rule IdentifierList
+ identifier Identifiers
+ end
+
+ rule Identifiers
+ ("," IdentifierList)?
+ end
+
+
+
+
# rule ExtendedAttribute
# "(" ws ExtendedAttributeInner ws ")" ws ExtendedAttributeRest
# / "[" ws ExtendedAttributeInner ws "]" ws ExtendedAttributeRest
# / "{" ws ExtendedAttributeInner ws "}" ws ExtendedAttributeRest
# / Other ws ExtendedAttributeRest
@@ -415,14 +431,23 @@
end
rule NonAnyType
type:PrimitiveType suffix:TypeSuffix <ParseTree::Type>
# added: cannot be followed by a NonSpace character, since e.g. DOMStringMap, DOMStringList or other identifiers would break parsing
+ / type:PromiseType Null { def build(parent); type.build(parent); end }
/ type:"DOMString" suffix:TypeSuffix !NonSpace <ParseTree::Type>
/ "sequence" ws "<" ws type:Type ws ">" null:Null <ParseTree::SequenceType>
/ type:"object" suffix:TypeSuffix <ParseTree::Type>
/ type:"Date" suffix:TypeSuffix <ParseTree::Type>
/ type:identifier suffix:TypeSuffix <ParseTree::Type>
+ end
+
+ rule PromiseType
+ "Promise" "<" return_type:ReturnType ">" {
+ def build(parent)
+ Ast::PromiseType.new(return_type.text_value)
+ end
+ }
end
rule ConstType
PrimitiveType Null
/ identifier Null