Skip to content

Commit

Permalink
Allow async and includes as member names (#385)
Browse files Browse the repository at this point in the history
saschanaz authored Aug 14, 2019
1 parent 2081fa9 commit 30f749b
Showing 7 changed files with 127 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/productions/attribute.js
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ export class Attribute extends Base {
case "sequence":
case "record": tokeniser.error(`Attributes cannot accept ${ret.idlType.generic} types`);
}
tokens.name = tokeniser.consume("identifier", "required") || tokeniser.error("Attribute lacks a name");
tokens.name = tokeniser.consume("identifier", "async", "required") || tokeniser.error("Attribute lacks a name");
tokens.termination = tokeniser.consume(";") || tokeniser.error("Unterminated attribute, expected `;`");
return ret;
}
2 changes: 1 addition & 1 deletion lib/productions/operation.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ export class Operation extends Base {
tokens.special = tokeniser.consume("getter", "setter", "deleter");
}
ret.idlType = return_type(tokeniser) || tokeniser.error("Missing return type");
tokens.name = tokeniser.consume("identifier");
tokens.name = tokeniser.consume("identifier", "includes");
tokens.open = tokeniser.consume("(") || tokeniser.error("Invalid operation");
ret.arguments = argument_list(tokeniser);
tokens.close = tokeniser.consume(")") || tokeniser.error("Unterminated operation");
1 change: 1 addition & 0 deletions lib/tokeniser.js
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ export const stringTypes = [
];

export const argumentNameKeywords = [
"async",
"attribute",
"callback",
"const",
73 changes: 73 additions & 0 deletions test/syntax/baseline/async-name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[
{
"type": "interface",
"name": "Async",
"inheritance": null,
"members": [
{
"type": "attribute",
"name": "async",
"idlType": {
"type": "attribute-type",
"extAttrs": [],
"generic": "",
"nullable": false,
"union": false,
"idlType": "boolean"
},
"extAttrs": [],
"special": "",
"readonly": false
},
{
"type": "operation",
"name": "asyncOp",
"idlType": {
"type": "return-type",
"extAttrs": [],
"generic": "",
"nullable": false,
"union": false,
"idlType": "void"
},
"arguments": [
{
"type": "argument",
"name": "async",
"extAttrs": [],
"idlType": {
"type": "argument-type",
"extAttrs": [],
"generic": "",
"nullable": false,
"union": false,
"idlType": "boolean"
},
"default": null,
"optional": false,
"variadic": false
}
],
"extAttrs": [],
"special": ""
}
],
"extAttrs": [
{
"type": "extended-attribute",
"name": "Exposed",
"rhs": {
"type": "identifier",
"value": "Window"
},
"arguments": []
}
],
"partial": false
},
{
"type": "eof",
"value": "",
"trivia": "\n"
}
]
41 changes: 41 additions & 0 deletions test/syntax/baseline/includes-name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[
{
"type": "interface",
"name": "Includes",
"inheritance": null,
"members": [
{
"type": "operation",
"name": "includes",
"idlType": {
"type": "return-type",
"extAttrs": [],
"generic": "",
"nullable": false,
"union": false,
"idlType": "void"
},
"arguments": [],
"extAttrs": [],
"special": ""
}
],
"extAttrs": [
{
"type": "extended-attribute",
"name": "Exposed",
"rhs": {
"type": "identifier",
"value": "Window"
},
"arguments": []
}
],
"partial": false
},
{
"type": "eof",
"value": "",
"trivia": "\n"
}
]
6 changes: 6 additions & 0 deletions test/syntax/idl/async-name.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[Exposed=Window]
interface Async {
attribute boolean async;
void asyncOp(boolean async);
};
4 changes: 4 additions & 0 deletions test/syntax/idl/includes-name.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Exposed=Window]
interface Includes {
void includes();
};

0 comments on commit 30f749b

Please sign in to comment.