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

fix: any not a keyword #439

Merged
merged 4 commits into from
Oct 3, 2019
Merged
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
4 changes: 2 additions & 2 deletions lib/productions/type.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Base } from "./base.js";
import { unescape, type_with_extended_attributes, return_type, primitive_type } from "./helpers.js";
import { stringTypes } from "../tokeniser.js";
import { stringTypes, typeNameKeywords } from "../tokeniser.js";
import { validationError } from "../error.js";
import { idlTypeIncludesDictionary } from "../validators/helpers.js";

Expand Down Expand Up @@ -62,7 +62,7 @@ function type_suffix(tokeniser, obj) {
function single_type(tokeniser, typeName) {
let ret = generic_type(tokeniser, typeName) || primitive_type(tokeniser);
if (!ret) {
const base = tokeniser.consume("identifier", ...stringTypes);
const base = tokeniser.consume("identifier", ...stringTypes, ...typeNameKeywords);
if (!base) {
return;
}
Expand Down
21 changes: 18 additions & 3 deletions lib/tokeniser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ const tokenRe = {
"other": /[^\t\n\r 0-9A-Za-z]/y
};

export const typeNameKeywords = [
"ArrayBuffer",
"DataView",
"Int8Array",
"Int16Array",
"Int32Array",
"Uint8Array",
"Uint16Array",
"Uint32Array",
"Uint8ClampedArray",
"Float32Array",
"Float64Array",
"any",
"object",
"symbol"
];

export const stringTypes = [
"ByteString",
"DOMString",
Expand Down Expand Up @@ -53,10 +70,8 @@ const nonRegexTerminals = [
"Infinity",
"NaN",
"Promise",
"async",
"boolean",
"byte",
"constructor",
"double",
"false",
"float",
Expand All @@ -73,7 +88,7 @@ const nonRegexTerminals = [
"true",
"unsigned",
"void"
].concat(argumentNameKeywords, stringTypes);
].concat(argumentNameKeywords, stringTypes, typeNameKeywords);

const punctuations = [
"(",
Expand Down
3 changes: 3 additions & 0 deletions test/invalid/baseline/any-keyword.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Syntax error at line 1 in any-keyword.webidl:
interface any {};
^ Missing name in interface
3 changes: 3 additions & 0 deletions test/invalid/baseline/int32array-keyword.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Syntax error at line 1 in int32array-keyword.webidl:
interface Int32Array {};
^ Missing name in interface
1 change: 1 addition & 0 deletions test/invalid/idl/any-keyword.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
interface any {};
1 change: 1 addition & 0 deletions test/invalid/idl/int32array-keyword.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
interface Int32Array {};