Comparing version 10.2.0 to 10.2.1
# Change Log | ||
## [v10.2.0](https://github.com/w3c/webidl2.js/tree/v10.2.0) (2018-01-30) | ||
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.1.0...v10.2.0) | ||
**Merged pull requests:** | ||
- Type on union idlType [\#135](https://github.com/w3c/webidl2.js/pull/135) ([saschanaz](https://github.com/saschanaz)) | ||
- feat: add argument/return type [\#134](https://github.com/w3c/webidl2.js/pull/134) ([saschanaz](https://github.com/saschanaz)) | ||
- feat: add dictionary/typedef-type [\#133](https://github.com/w3c/webidl2.js/pull/133) ([saschanaz](https://github.com/saschanaz)) | ||
- feat: add const-type for idlTypes [\#132](https://github.com/w3c/webidl2.js/pull/132) ([saschanaz](https://github.com/saschanaz)) | ||
- feat: add types on idlTypes [\#131](https://github.com/w3c/webidl2.js/pull/131) ([saschanaz](https://github.com/saschanaz)) | ||
- Auto acquisition for parser result changes [\#130](https://github.com/w3c/webidl2.js/pull/130) ([saschanaz](https://github.com/saschanaz)) | ||
## [v10.1.0](https://github.com/w3c/webidl2.js/tree/v10.1.0) (2018-01-19) | ||
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.0.0...v10.1.0) | ||
**Closed issues:** | ||
- Support `raises` and `setraises` [\#128](https://github.com/w3c/webidl2.js/issues/128) | ||
- Support `legacycaller` [\#127](https://github.com/w3c/webidl2.js/issues/127) | ||
- Improve "No semicolon after enum" message [\#119](https://github.com/w3c/webidl2.js/issues/119) | ||
**Merged pull requests:** | ||
- Let error messages include the current definition name [\#129](https://github.com/w3c/webidl2.js/pull/129) ([saschanaz](https://github.com/saschanaz)) | ||
## [v10.0.0](https://github.com/w3c/webidl2.js/tree/v10.0.0) (2017-12-20) | ||
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v9.0.0...v10.0.0) | ||
**Closed issues:** | ||
- Always return an array for idlType, etc. [\#113](https://github.com/w3c/webidl2.js/issues/113) | ||
- Maintain writer.js or not? [\#109](https://github.com/w3c/webidl2.js/issues/109) | ||
**Merged pull requests:** | ||
- Remove typeExtAttrs from docs [\#124](https://github.com/w3c/webidl2.js/pull/124) ([saschanaz](https://github.com/saschanaz)) | ||
- Remove iterator documentation [\#123](https://github.com/w3c/webidl2.js/pull/123) ([saschanaz](https://github.com/saschanaz)) | ||
- Maintain writer.js [\#122](https://github.com/w3c/webidl2.js/pull/122) ([saschanaz](https://github.com/saschanaz)) | ||
- BREAKING CHANGE: remove deprecated iterator operation [\#121](https://github.com/w3c/webidl2.js/pull/121) ([saschanaz](https://github.com/saschanaz)) | ||
- Use for-of on tests [\#120](https://github.com/w3c/webidl2.js/pull/120) ([saschanaz](https://github.com/saschanaz)) | ||
- docs\(README\): iterables ildType is always array [\#118](https://github.com/w3c/webidl2.js/pull/118) ([marcoscaceres](https://github.com/marcoscaceres)) | ||
## [v9.0.0](https://github.com/w3c/webidl2.js/tree/v9.0.0) (2017-11-30) | ||
@@ -4,0 +46,0 @@ [Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.1.0...v9.0.0) |
"use strict"; | ||
(() => { | ||
// These regular expressions use the sticky flag so they will only match at | ||
// the current location (ie. the offset of lastIndex). | ||
const tokenRe = { | ||
// This expression uses a lookahead assertion to catch false matches | ||
// against integers early. | ||
"float": /-?(?=[0-9]*\.|[0-9]+[eE])(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/y, | ||
"integer": /-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/y, | ||
"identifier": /[A-Z_a-z][0-9A-Z_a-z-]*/y, | ||
"string": /"[^"]*"/y, | ||
"whitespace": /[\t\n\r ]+/y, | ||
"comment": /((\/(\/.*|\*([^*]|\*[^\/])*\*\/)[\t\n\r ]*)+)/y, | ||
"other": /[^\t\n\r 0-9A-Z_a-z]/y | ||
}; | ||
function attemptTokenMatch(str, type, re, lastIndex, tokens) { | ||
re.lastIndex = lastIndex; | ||
const result = re.exec(str); | ||
if (result) { | ||
tokens.push({ type, value: result[0] }); | ||
return re.lastIndex; | ||
} | ||
return -1; | ||
} | ||
function tokenise(str) { | ||
const tokens = []; | ||
const re = { | ||
"float": /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/, | ||
"integer": /^-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/, | ||
"identifier": /^[A-Z_a-z][0-9A-Z_a-z-]*/, | ||
"string": /^"[^"]*"/, | ||
"whitespace": /^(?:[\t\n\r ]+|[\t\n\r ]*((\/\/.*|\/\*(.|\n|\r)*?\*\/)[\t\n\r ]*))+/, | ||
"other": /^[^\t\n\r 0-9A-Z_a-z]/ | ||
}; | ||
const types = ["float", "integer", "identifier", "string", "whitespace", "other"]; | ||
while (str.length > 0) { | ||
let matched = false; | ||
for (const type of types) { | ||
str = str.replace(re[type], tok => { | ||
tokens.push({ type, value: tok }); | ||
matched = true; | ||
return ""; | ||
}); | ||
if (matched) break; | ||
let lastIndex = 0; | ||
while (lastIndex < str.length) { | ||
const nextChar = str.charAt(lastIndex); | ||
let result = -1; | ||
if (/[-0-9.]/.test(nextChar)) { | ||
result = attemptTokenMatch(str, "float", tokenRe.float, lastIndex, | ||
tokens); | ||
if (result === -1) { | ||
result = attemptTokenMatch(str, "integer", tokenRe.integer, lastIndex, | ||
tokens); | ||
} | ||
if (result === -1) { | ||
// '-' and '.' can also match "other". | ||
result = attemptTokenMatch(str, "other", tokenRe.other, | ||
lastIndex, tokens); | ||
} | ||
} else if (/[A-Z_a-z]/.test(nextChar)) { | ||
result = attemptTokenMatch(str, "identifier", tokenRe.identifier, | ||
lastIndex, tokens); | ||
} else if (nextChar === '"') { | ||
result = attemptTokenMatch(str, "string", tokenRe.string, | ||
lastIndex, tokens); | ||
if (result === -1) { | ||
// '"' can also match "other". | ||
result = attemptTokenMatch(str, "other", tokenRe.other, | ||
lastIndex, tokens); | ||
} | ||
} else if (/[\t\n\r ]/.test(nextChar)) { | ||
result = attemptTokenMatch(str, "whitespace", tokenRe.whitespace, | ||
lastIndex, tokens); | ||
} else if (nextChar === '/') { | ||
// The parser expects comments to be labelled as "whitespace". | ||
result = attemptTokenMatch(str, "whitespace", tokenRe.comment, | ||
lastIndex, tokens); | ||
if (result === -1) { | ||
// '/' can also match "other". | ||
result = attemptTokenMatch(str, "other", tokenRe.other, | ||
lastIndex, tokens); | ||
} | ||
} else { | ||
result = attemptTokenMatch(str, "other", tokenRe.other, | ||
lastIndex, tokens); | ||
} | ||
if (matched) continue; | ||
throw new Error("Token stream not progressing"); | ||
if (result === -1) { | ||
throw new Error("Token stream not progressing"); | ||
} | ||
lastIndex = result; | ||
} | ||
return tokens; | ||
}; | ||
} | ||
@@ -61,3 +111,3 @@ class WebIDLParseError { | ||
deleter: false, | ||
"static": false, | ||
static: false, | ||
stringifier: false | ||
@@ -85,3 +135,3 @@ }); | ||
throw new WebIDLParseError(message, line, tok, tokens.slice(0, maxTokens)); | ||
}; | ||
} | ||
@@ -102,7 +152,16 @@ function sanitize_name(name, type) { | ||
last_token = tokens.shift(); | ||
if (type === ID) last_token.value = last_token.value.replace(/^_/, ""); | ||
if (type === ID && last_token.value.startsWith('_')) | ||
last_token.value = last_token.value.substring(1); | ||
return last_token; | ||
} | ||
}; | ||
} | ||
function count(str, char) { | ||
let total = 0; | ||
for (let i = str.indexOf(char); i !== -1; i = str.indexOf(char, i + 1)) { | ||
++total; | ||
} | ||
return total; | ||
} | ||
function ws() { | ||
@@ -112,10 +171,12 @@ if (!tokens.length) return; | ||
const t = tokens.shift(); | ||
t.value.replace(/\n/g, m => { | ||
line++; | ||
return m; | ||
}); | ||
line += count(t.value, '\n'); | ||
return t; | ||
} | ||
} | ||
const all_ws_re = { | ||
"ws": /([\t\n\r ]+)/y, | ||
"line-comment": /\/\/(.*)\r?\n?/y, | ||
"multiline-comment": /\/\*((?:[^*]|\*[^/])*)\*\//y | ||
}; | ||
function all_ws(store, pea) { // pea == post extended attribute, tpea = same for types | ||
@@ -131,21 +192,21 @@ const t = { type: "whitespace", value: "" }; | ||
let w = t.value; | ||
const re = { | ||
"ws": /^([\t\n\r ]+)/, | ||
"line-comment": /^\/\/(.*)\r?\n?/, | ||
"multiline-comment": /^\/\*((?:.|\n|\r)*?)\*\// | ||
}; | ||
const wsTypes = []; | ||
for (const k in re) wsTypes.push(k); | ||
while (w.length) { | ||
let lastIndex = 0; | ||
while (lastIndex < w.length) { | ||
let matched = false; | ||
for (const type of wsTypes) { | ||
w = w.replace(re[type], (tok, m1) => { | ||
store.push({ type: type + (pea ? ("-" + pea) : ""), value: m1 }); | ||
// Servo doesn't support using "const" in this construction yet. | ||
// See https://github.com/servo/servo/issues/20231. | ||
// |type| can be made const once Servo supports it. | ||
for (let type in all_ws_re) { | ||
const re = all_ws_re[type]; | ||
re.lastIndex = lastIndex; | ||
const result = re.exec(w); | ||
if (result) { | ||
store.push({ type: type + (pea ? ("-" + pea) : ""), value: result[1] }); | ||
matched = true; | ||
return ""; | ||
}); | ||
if (matched) break; | ||
lastIndex = re.lastIndex; | ||
break; | ||
} | ||
} | ||
if (matched) continue; | ||
throw new Error("Surprising white space construct."); // this shouldn't happen | ||
if (!matched) | ||
throw new Error("Surprising white space construct."); // this shouldn't happen | ||
} | ||
@@ -155,3 +216,3 @@ } | ||
} | ||
}; | ||
} | ||
@@ -171,3 +232,3 @@ function integer_type() { | ||
if (ret) error("Failed to parse integer type"); | ||
}; | ||
} | ||
@@ -182,3 +243,3 @@ function float_type() { | ||
if (ret) error("Failed to parse float type"); | ||
}; | ||
} | ||
@@ -192,3 +253,3 @@ function primitive_type() { | ||
if (consume(ID, "octet")) return "octet"; | ||
}; | ||
} | ||
@@ -208,3 +269,3 @@ function const_value() { | ||
} | ||
}; | ||
} | ||
@@ -219,3 +280,3 @@ function type_suffix(obj) { | ||
} | ||
}; | ||
} | ||
@@ -271,3 +332,3 @@ function single_type(typeName) { | ||
return ret; | ||
}; | ||
} | ||
@@ -289,7 +350,7 @@ function union_type(typeName) { | ||
return ret; | ||
}; | ||
} | ||
function type(typeName) { | ||
return single_type(typeName) || union_type(typeName); | ||
}; | ||
} | ||
@@ -301,3 +362,3 @@ function type_with_extended_attributes(typeName) { | ||
return ret; | ||
}; | ||
} | ||
@@ -348,3 +409,3 @@ function argument(store) { | ||
return ret; | ||
}; | ||
} | ||
@@ -362,3 +423,3 @@ function argument_list(store) { | ||
} | ||
}; | ||
} | ||
@@ -414,3 +475,3 @@ function simple_extended_attr(store) { | ||
return ret; | ||
}; | ||
} | ||
@@ -435,3 +496,3 @@ // Note: we parse something simpler than the official syntax. It's all that ever | ||
return eas; | ||
}; | ||
} | ||
@@ -450,7 +511,7 @@ function default_() { | ||
const str = consume(STR) || error("No value for default"); | ||
str.value = str.value.replace(/^"/, "").replace(/"$/, ""); | ||
str.value = str.value.slice(1, -1); | ||
return str; | ||
} | ||
} | ||
}; | ||
} | ||
@@ -484,3 +545,3 @@ function const_(store) { | ||
return ret; | ||
}; | ||
} | ||
@@ -494,3 +555,3 @@ function inheritance() { | ||
} | ||
}; | ||
} | ||
@@ -510,3 +571,3 @@ function operation_rest(ret, store) { | ||
return ret; | ||
}; | ||
} | ||
@@ -537,3 +598,3 @@ function callback(store) { | ||
return ret; | ||
}; | ||
} | ||
@@ -545,3 +606,3 @@ function attribute(store) { | ||
type: "attribute", | ||
"static": false, | ||
static: false, | ||
stringifier: false, | ||
@@ -554,3 +615,3 @@ inherit: false, | ||
if (consume(ID, "inherit")) { | ||
if (ret["static"] || ret.stringifier) error("Cannot have a static or stringifier inherit"); | ||
if (ret.static || ret.stringifier) error("Cannot have a static or stringifier inherit"); | ||
ret.inherit = true; | ||
@@ -572,3 +633,3 @@ grabbed.push(last_token); | ||
return rest; | ||
}; | ||
} | ||
@@ -589,3 +650,3 @@ function attribute_rest(ret) { | ||
return ret; | ||
}; | ||
} | ||
@@ -600,3 +661,3 @@ function return_type() { | ||
return typ; | ||
}; | ||
} | ||
@@ -623,3 +684,3 @@ function operation(store) { | ||
return ret; | ||
}; | ||
} | ||
@@ -656,3 +717,3 @@ function static_member(store) { | ||
} | ||
}; | ||
} | ||
@@ -665,3 +726,3 @@ function iterable_type() { | ||
else return; | ||
}; | ||
} | ||
@@ -672,3 +733,3 @@ function readonly_iterable_type() { | ||
else return; | ||
}; | ||
} | ||
@@ -718,3 +779,3 @@ function iterable(store) { | ||
return ret; | ||
}; | ||
} | ||
@@ -759,3 +820,3 @@ function interface_rest(isPartial, store, typeName = "interface") { | ||
} | ||
}; | ||
} | ||
@@ -844,3 +905,3 @@ function mixin_rest(isPartial, store) { | ||
type: "attribute", | ||
"static": false, | ||
static: false, | ||
stringifier: false, | ||
@@ -885,3 +946,3 @@ inherit: false, | ||
return thing; | ||
}; | ||
} | ||
@@ -932,3 +993,3 @@ function dictionary(isPartial, store) { | ||
} | ||
}; | ||
} | ||
@@ -957,3 +1018,3 @@ function enum_(store) { | ||
const val = consume(STR) || error("Unexpected value in enum"); | ||
val.value = val.value.replace(/"/g, ""); | ||
val.value = val.value.slice(1, -1); | ||
ret.values.push(val); | ||
@@ -969,3 +1030,3 @@ all_ws(store ? vals : null); | ||
} | ||
}; | ||
} | ||
@@ -987,3 +1048,3 @@ function typedef(store) { | ||
return ret; | ||
}; | ||
} | ||
@@ -1011,3 +1072,3 @@ function implements_(store) { | ||
} | ||
}; | ||
} | ||
@@ -1035,3 +1096,3 @@ function includes(store) { | ||
} | ||
}; | ||
} | ||
@@ -1048,3 +1109,3 @@ function definition(store) { | ||
namespace(false, store); | ||
}; | ||
} | ||
@@ -1065,7 +1126,7 @@ function definitions(store) { | ||
return defs; | ||
}; | ||
} | ||
const res = definitions(opt.ws); | ||
if (tokens.length) error("Unrecognised tokens"); | ||
return res; | ||
}; | ||
} | ||
@@ -1072,0 +1133,0 @@ const obj = { |
@@ -226,3 +226,3 @@ "use strict"; | ||
"multiline-comment": multilineComment, | ||
"interface": interface_, | ||
interface: interface_, | ||
"interface mixin": interface_mixin, | ||
@@ -234,8 +234,8 @@ namespace, | ||
field, | ||
"const": const_, | ||
const: const_, | ||
typedef, | ||
"implements": implements_, | ||
implements: implements_, | ||
includes, | ||
callback, | ||
"enum": enum_, | ||
enum: enum_, | ||
iterable, | ||
@@ -265,5 +265,3 @@ legacyiterable, | ||
const obj = { | ||
write(ast, opt = {}) { | ||
return write(ast, opt); | ||
} | ||
write | ||
}; | ||
@@ -270,0 +268,0 @@ |
{ | ||
"name": "webidl2", | ||
"description": "A WebIDL Parser", | ||
"version": "10.2.0", | ||
"version": "10.2.1", | ||
"contributors": [ | ||
@@ -14,5 +14,5 @@ "Robin Berjon <robin@berjon.com> (https://berjon.com)", | ||
"devDependencies": { | ||
"expect": "22.1.0", | ||
"jsondiffpatch": "0.2.5", | ||
"mocha": "5.0.0" | ||
"expect": "22.4.0", | ||
"jsondiffpatch": "0.3.5", | ||
"mocha": "5.0.4" | ||
}, | ||
@@ -19,0 +19,0 @@ "scripts": { |
@@ -34,3 +34,3 @@ "use strict"; | ||
else { | ||
throw e; | ||
throw error; | ||
} | ||
@@ -37,0 +37,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
893785
321
7715