Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Documentation extended attribute used with CSSOM specs. #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ node/WebIDLParser.js: lib/grammar.peg
web/WebIDLParser.js: lib/grammar.peg
pegjs < lib/grammar.peg | sed -e 's/module.exports =/window.WebIDLParser =/' > web/WebIDLParser.js

clean:
$(RM) node/WebIDLParser.js web/WebIDLParser.js
51 changes: 26 additions & 25 deletions lib/grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -168,40 +168,40 @@ definition

// partial interface definition
partialinterface
= extAttrs:extendedAttributeList? S? "partial" S "interface" S name:identifier w "{" w mem:ifMember* w "}" w ";" w
= extAttrs:extendedAttributeList? w "partial" S "interface" S name:identifier w "{" w mem:ifMember* w "}" w ";" w
{ return { type: "partialinterface", name: name, members: mem, extAttrs: extAttrs }; }

// callback interface definition
callbackinterface
= extAttrs:extendedAttributeList? S? "callback" S "interface" S name:identifier w "{" w mem:ifMember* w "}" w ";" w
= extAttrs:extendedAttributeList? w "callback" S "interface" S name:identifier w "{" w mem:ifMember* w "}" w ";" w
{ return { type: "callbackinterface", name: name, members: mem, extAttrs: extAttrs }; }


// module definition
module
= extAttrs:extendedAttributeList? S? "module" S name:identifier w "{" w defs:definitions w "}" w ";" w
= extAttrs:extendedAttributeList? w "module" S name:identifier w "{" w defs:definitions w "}" w ";" w
{ return { type: "module", name: name, definitions: defs, extAttrs: extAttrs }; }


// implements definition
implements
= extAttrs:extendedAttributeList? S? target:ScopedName S "implements" S impl:ScopedName w ";" w
= extAttrs:extendedAttributeList? w target:ScopedName S "implements" S impl:ScopedName w ";" w
{ return { type: 'implements', target: target, 'implements': impl, extAttrs: extAttrs }; }


// interface definition
interface
= extAttrs:extendedAttributeList? S? "interface" S name:identifier w herit:ifInheritance? w "{" w mem:ifMember* w "}" w ";" w
= extAttrs:extendedAttributeList? w "interface" S name:identifier w herit:ifInheritance? w "{" w mem:ifMember* w "}" w ";" w
{ return { type: "interface", name: name, inheritance: herit, members: mem, extAttrs: extAttrs }; }

// enum definition
enum
= extAttrs:extendedAttributeList? S? "enum" S name:identifier w "{" w values:EnumValues w "}" w ";" w
= extAttrs:extendedAttributeList? w "enum" S name:identifier w "{" w values:EnumValues w "}" w ";" w
{ return { type: "enum", name: name, values: values, extAttrs: extAttrs }; }

// callback definition
callback
= extAttrs:extendedAttributeList? S? "callback" S name:identifier w "=" w ret:ReturnType S "(" w args:Arguments w ")" w ";" w
= extAttrs:extendedAttributeList? w "callback" S name:identifier w "=" w ret:ReturnType S "(" w args:Arguments w ")" w ";" w
{ return { type: "callback", idlType: ret, name: name, args: args, extAttrs: extAttrs }; }

EnumValues
Expand All @@ -220,12 +220,15 @@ ifInheritance
{ return herit; }

ifMember
= mem:(const / attrOrOp)
{ return mem; }
= extAttrs:extendedAttributeList? w mem:(const / attrOrOp)
{
if ( extAttrs ) { mem.extAttrs = extAttrs };
return mem;
}

const
= extAttrs:extendedAttributeList? S? "const" S type:type S name:identifier w "=" w value:constExpr w ";" w
{ return { type: "const", extAttrs: extAttrs, idlType: type, name: name, value: value }; }
= "const" S type:type S name:identifier w "=" w value:constExpr w ";" w
{ return { type: "const", idlType: type, name: name, value: value }; }

constExpr
= value:(BooleanLiteral / float / integer / "NaN" / "null")
Expand All @@ -246,8 +249,8 @@ Stringifier
}

Attribute
= extAttrs:extendedAttributeList? w ro:("readonly" S)? "attribute" S type:type S name:identifier w gr:GetRaises? w sr:SetRaises? w ";" w
{ return { type: "attribute", extAttrs: extAttrs, idlType: type, name: name, readonly: (ro ? true : false), getraises: gr, setraises: sr }; }
= ro:("readonly" S)? "attribute" S type:type S name:identifier w gr:GetRaises? w sr:SetRaises? w ";" w
{ return { type: "attribute", idlType: type, name: name, readonly: (ro ? true : false), getraises: gr, setraises: sr }; }

GetRaises
= "getraises" w "(" list:ScopedNameList ")"
Expand All @@ -258,10 +261,9 @@ SetRaises
{ return list; }

Operation
= extAttrs:extendedAttributeList? w quals:Qualifiers w rest:OperationRest
= quals:Qualifiers w rest:OperationRest
{
for (var k in quals) rest[k] = quals[k];
if (extAttrs) rest.extAttrs = extAttrs;
return rest;
}

Expand Down Expand Up @@ -328,8 +330,8 @@ defaultValue

// typedef definition
typedef
= "typedef" S type:type S name:identifier w ";" w
{ return { type: 'typedef', name: name, idlType: type }; }
= "typedef" S extAttrs:extendedAttributeList? w type:type S name:identifier w ";" w
{ return { type: 'typedef', name: name, idlType: type, extAttrs: extAttrs }; }

// exception definition
exception
Expand All @@ -341,7 +343,7 @@ exMember
{ return mem; }

field
= extAttrs:extendedAttributeList? S? type:type S name:identifier w ";" w
= extAttrs:extendedAttributeList? w type:type S name:identifier w ";" w
{ return { type: "field", extAttrs: extAttrs, idlType: type, name: name }; }


Expand All @@ -361,25 +363,24 @@ ExtAttrsRest
{ return rest; }

ExtAttr
= ea:(ExtAttrArgList / ExtAttrNamedArgList / ExtAttrNameValue / ExtAttrNoArg)
{ return ea; }
= extAttrs:extendedAttributeList? w ea:(ExtAttrArgList / ExtAttrNamedArgList / ExtAttrNameValue / ExtAttrNoArg)
{
if ( extAttrs ) { ea.extAttrs = extAttrs };
return ea;
}

ExtAttrNoArg
= name:identifier
{return { name: name }; }

ExtAttrNameValue
= name:identifier w "=" w value:ScopedName
= name:identifier w "=" w value:(ScopedName / string)
{return { name: name, value: value }; }

ExtAttrNamedArgList
= name:identifier w "=" w value:identifier w "(" w args:Arguments? w ")"
{return { name: name, value: value, arguments: args }; }

ExtAttrNamedArgList
= name:identifier w "=" w value:identifier w "(" w args:Arguments? w ")"
{return { name: name, value: value, arguments: args }; }

ExtAttrArgList
= name:identifier w "(" w args:Arguments? w ")"
{return { name: name, arguments: args }; }
Expand Down
Loading