mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
21
web/node_modules/@webassemblyjs/wast-parser/LICENSE
generated
vendored
Normal file
21
web/node_modules/@webassemblyjs/wast-parser/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018 Sven Sauleau <sven@sauleau.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
17
web/node_modules/@webassemblyjs/wast-parser/README.md
generated
vendored
Normal file
17
web/node_modules/@webassemblyjs/wast-parser/README.md
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# @webassemblyjs/wast-parser
|
||||
|
||||
> WebAssembly text format parser
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
yarn add @webassemblyjs/wast-parser
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { parse } from "@webassemblyjs/wast-parser";
|
||||
|
||||
const ast = parse(source);
|
||||
```
|
1756
web/node_modules/@webassemblyjs/wast-parser/esm/grammar.js
generated
vendored
Normal file
1756
web/node_modules/@webassemblyjs/wast-parser/esm/grammar.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
9
web/node_modules/@webassemblyjs/wast-parser/esm/index.js
generated
vendored
Normal file
9
web/node_modules/@webassemblyjs/wast-parser/esm/index.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
import * as parser from "./grammar";
|
||||
import { tokenize } from "./tokenizer";
|
||||
export function parse(source) {
|
||||
var tokens = tokenize(source); // We pass the source here to show code frames
|
||||
|
||||
var ast = parser.parse(tokens, source);
|
||||
return ast;
|
||||
}
|
||||
export * from "./number-literals";
|
91
web/node_modules/@webassemblyjs/wast-parser/esm/number-literals.js
generated
vendored
Normal file
91
web/node_modules/@webassemblyjs/wast-parser/esm/number-literals.js
generated
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
import Long from "@xtuc/long";
|
||||
import parseHexFloat from "@webassemblyjs/floating-point-hex-parser";
|
||||
import { CompileError } from "@webassemblyjs/helper-api-error";
|
||||
export function parse32F(sourceString) {
|
||||
if (isHexLiteral(sourceString)) {
|
||||
return parseHexFloat(sourceString);
|
||||
}
|
||||
|
||||
if (isInfLiteral(sourceString)) {
|
||||
return sourceString[0] === "-" ? -1 : 1;
|
||||
}
|
||||
|
||||
if (isNanLiteral(sourceString)) {
|
||||
return (sourceString[0] === "-" ? -1 : 1) * (sourceString.includes(":") ? parseInt(sourceString.substring(sourceString.indexOf(":") + 1), 16) : 0x400000);
|
||||
}
|
||||
|
||||
return parseFloat(sourceString);
|
||||
}
|
||||
export function parse64F(sourceString) {
|
||||
if (isHexLiteral(sourceString)) {
|
||||
return parseHexFloat(sourceString);
|
||||
}
|
||||
|
||||
if (isInfLiteral(sourceString)) {
|
||||
return sourceString[0] === "-" ? -1 : 1;
|
||||
}
|
||||
|
||||
if (isNanLiteral(sourceString)) {
|
||||
return (sourceString[0] === "-" ? -1 : 1) * (sourceString.includes(":") ? parseInt(sourceString.substring(sourceString.indexOf(":") + 1), 16) : 0x8000000000000);
|
||||
}
|
||||
|
||||
if (isHexLiteral(sourceString)) {
|
||||
return parseHexFloat(sourceString);
|
||||
}
|
||||
|
||||
return parseFloat(sourceString);
|
||||
}
|
||||
export function parse32I(sourceString) {
|
||||
var value = 0;
|
||||
|
||||
if (isHexLiteral(sourceString)) {
|
||||
value = ~~parseInt(sourceString, 16);
|
||||
} else if (isDecimalExponentLiteral(sourceString)) {
|
||||
throw new Error("This number literal format is yet to be implemented.");
|
||||
} else {
|
||||
value = parseInt(sourceString, 10);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
export function parseU32(sourceString) {
|
||||
var value = parse32I(sourceString);
|
||||
|
||||
if (value < 0) {
|
||||
throw new CompileError("Illegal value for u32: " + sourceString);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
export function parse64I(sourceString) {
|
||||
var long;
|
||||
|
||||
if (isHexLiteral(sourceString)) {
|
||||
long = Long.fromString(sourceString, false, 16);
|
||||
} else if (isDecimalExponentLiteral(sourceString)) {
|
||||
throw new Error("This number literal format is yet to be implemented.");
|
||||
} else {
|
||||
long = Long.fromString(sourceString);
|
||||
}
|
||||
|
||||
return {
|
||||
high: long.high,
|
||||
low: long.low
|
||||
};
|
||||
}
|
||||
var NAN_WORD = /^\+?-?nan/;
|
||||
var INF_WORD = /^\+?-?inf/;
|
||||
export function isInfLiteral(sourceString) {
|
||||
return INF_WORD.test(sourceString.toLowerCase());
|
||||
}
|
||||
export function isNanLiteral(sourceString) {
|
||||
return NAN_WORD.test(sourceString.toLowerCase());
|
||||
}
|
||||
|
||||
function isDecimalExponentLiteral(sourceString) {
|
||||
return !isHexLiteral(sourceString) && sourceString.toUpperCase().includes("E");
|
||||
}
|
||||
|
||||
function isHexLiteral(sourceString) {
|
||||
return sourceString.substring(0, 2).toUpperCase() === "0X" || sourceString.substring(0, 3).toUpperCase() === "-0X";
|
||||
}
|
88
web/node_modules/@webassemblyjs/wast-parser/esm/string-literals.js
generated
vendored
Normal file
88
web/node_modules/@webassemblyjs/wast-parser/esm/string-literals.js
generated
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
// string literal characters cannot contain control codes
|
||||
var CONTROL_CODES = [0, // null
|
||||
7, // bell
|
||||
8, // backspace
|
||||
9, // horizontal
|
||||
10, // line feed
|
||||
11, // vertical tab
|
||||
12, // form feed
|
||||
13, // carriage return
|
||||
26, // Control-Z
|
||||
27, // escape
|
||||
127 // delete
|
||||
]; // escaped sequences can either be a two character hex value, or one of the
|
||||
// following single character codes
|
||||
|
||||
function decodeControlCharacter(char) {
|
||||
switch (char) {
|
||||
case "t":
|
||||
return 0x09;
|
||||
|
||||
case "n":
|
||||
return 0x0a;
|
||||
|
||||
case "r":
|
||||
return 0x0d;
|
||||
|
||||
case '"':
|
||||
return 0x22;
|
||||
|
||||
case "′":
|
||||
return 0x27;
|
||||
|
||||
case "\\":
|
||||
return 0x5c;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
var ESCAPE_CHAR = 92; // backslash
|
||||
|
||||
var QUOTE_CHAR = 34; // backslash
|
||||
// parse string as per the spec:
|
||||
// https://webassembly.github.io/spec/core/multipage/text/values.html#text-string
|
||||
|
||||
export function parseString(value) {
|
||||
var byteArray = [];
|
||||
var index = 0;
|
||||
|
||||
while (index < value.length) {
|
||||
var charCode = value.charCodeAt(index);
|
||||
|
||||
if (CONTROL_CODES.indexOf(charCode) !== -1) {
|
||||
throw new Error("ASCII control characters are not permitted within string literals");
|
||||
}
|
||||
|
||||
if (charCode === QUOTE_CHAR) {
|
||||
throw new Error("quotes are not permitted within string literals");
|
||||
}
|
||||
|
||||
if (charCode === ESCAPE_CHAR) {
|
||||
var firstChar = value.substr(index + 1, 1);
|
||||
var decodedControlChar = decodeControlCharacter(firstChar);
|
||||
|
||||
if (decodedControlChar !== -1) {
|
||||
// single character escaped values, e.g. \r
|
||||
byteArray.push(decodedControlChar);
|
||||
index += 2;
|
||||
} else {
|
||||
// hex escaped values, e.g. \2a
|
||||
var hexValue = value.substr(index + 1, 2);
|
||||
|
||||
if (!/^[0-9A-F]{2}$/i.test(hexValue)) {
|
||||
throw new Error("invalid character encoding");
|
||||
}
|
||||
|
||||
byteArray.push(parseInt(hexValue, 16));
|
||||
index += 3;
|
||||
}
|
||||
} else {
|
||||
// ASCII encoded values
|
||||
byteArray.push(charCode);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return byteArray;
|
||||
}
|
434
web/node_modules/@webassemblyjs/wast-parser/esm/tokenizer.js
generated
vendored
Normal file
434
web/node_modules/@webassemblyjs/wast-parser/esm/tokenizer.js
generated
vendored
Normal file
|
@ -0,0 +1,434 @@
|
|||
import { FSM, makeTransition } from "@webassemblyjs/helper-fsm";
|
||||
import { codeFrameFromSource } from "@webassemblyjs/helper-code-frame";
|
||||
|
||||
// eslint-disable-next-line
|
||||
function getCodeFrame(source, line, column) {
|
||||
var loc = {
|
||||
start: {
|
||||
line: line,
|
||||
column: column
|
||||
}
|
||||
};
|
||||
return "\n" + codeFrameFromSource(source, loc) + "\n";
|
||||
}
|
||||
|
||||
var WHITESPACE = /\s/;
|
||||
var PARENS = /\(|\)/;
|
||||
var LETTERS = /[a-z0-9_/]/i;
|
||||
var idchar = /[a-z0-9!#$%&*+./:<=>?@\\[\]^_`|~-]/i;
|
||||
var valtypes = ["i32", "i64", "f32", "f64"];
|
||||
var NUMBERS = /[0-9|.|_]/;
|
||||
var NUMBER_KEYWORDS = /nan|inf/;
|
||||
|
||||
function isNewLine(char) {
|
||||
return char.charCodeAt(0) === 10 || char.charCodeAt(0) === 13;
|
||||
}
|
||||
|
||||
function Token(type, value, start, end) {
|
||||
var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
||||
var token = {
|
||||
type: type,
|
||||
value: value,
|
||||
loc: {
|
||||
start: start,
|
||||
end: end
|
||||
}
|
||||
};
|
||||
|
||||
if (Object.keys(opts).length > 0) {
|
||||
// $FlowIgnore
|
||||
token["opts"] = opts;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
var tokenTypes = {
|
||||
openParen: "openParen",
|
||||
closeParen: "closeParen",
|
||||
number: "number",
|
||||
string: "string",
|
||||
name: "name",
|
||||
identifier: "identifier",
|
||||
valtype: "valtype",
|
||||
dot: "dot",
|
||||
comment: "comment",
|
||||
equal: "equal",
|
||||
keyword: "keyword"
|
||||
};
|
||||
export var keywords = {
|
||||
module: "module",
|
||||
func: "func",
|
||||
param: "param",
|
||||
result: "result",
|
||||
export: "export",
|
||||
loop: "loop",
|
||||
block: "block",
|
||||
if: "if",
|
||||
then: "then",
|
||||
else: "else",
|
||||
call: "call",
|
||||
call_indirect: "call_indirect",
|
||||
import: "import",
|
||||
memory: "memory",
|
||||
table: "table",
|
||||
global: "global",
|
||||
anyfunc: "anyfunc",
|
||||
mut: "mut",
|
||||
data: "data",
|
||||
type: "type",
|
||||
elem: "elem",
|
||||
start: "start",
|
||||
offset: "offset"
|
||||
};
|
||||
var NUMERIC_SEPARATOR = "_";
|
||||
/**
|
||||
* Build the FSM for number literals
|
||||
*/
|
||||
|
||||
var numberLiteralFSM = new FSM({
|
||||
START: [makeTransition(/-|\+/, "AFTER_SIGN"), makeTransition(/nan:0x/, "NAN_HEX", {
|
||||
n: 6
|
||||
}), makeTransition(/nan|inf/, "STOP", {
|
||||
n: 3
|
||||
}), makeTransition(/0x/, "HEX", {
|
||||
n: 2
|
||||
}), makeTransition(/[0-9]/, "DEC"), makeTransition(/\./, "DEC_FRAC")],
|
||||
AFTER_SIGN: [makeTransition(/nan:0x/, "NAN_HEX", {
|
||||
n: 6
|
||||
}), makeTransition(/nan|inf/, "STOP", {
|
||||
n: 3
|
||||
}), makeTransition(/0x/, "HEX", {
|
||||
n: 2
|
||||
}), makeTransition(/[0-9]/, "DEC"), makeTransition(/\./, "DEC_FRAC")],
|
||||
DEC_FRAC: [makeTransition(/[0-9]/, "DEC_FRAC", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
}), makeTransition(/e|E/, "DEC_SIGNED_EXP")],
|
||||
DEC: [makeTransition(/[0-9]/, "DEC", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
}), makeTransition(/\./, "DEC_FRAC"), makeTransition(/e|E/, "DEC_SIGNED_EXP")],
|
||||
DEC_SIGNED_EXP: [makeTransition(/\+|-/, "DEC_EXP"), makeTransition(/[0-9]/, "DEC_EXP")],
|
||||
DEC_EXP: [makeTransition(/[0-9]/, "DEC_EXP", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
})],
|
||||
HEX: [makeTransition(/[0-9|A-F|a-f]/, "HEX", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
}), makeTransition(/\./, "HEX_FRAC"), makeTransition(/p|P/, "HEX_SIGNED_EXP")],
|
||||
HEX_FRAC: [makeTransition(/[0-9|A-F|a-f]/, "HEX_FRAC", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
}), makeTransition(/p|P|/, "HEX_SIGNED_EXP")],
|
||||
HEX_SIGNED_EXP: [makeTransition(/[0-9|+|-]/, "HEX_EXP")],
|
||||
HEX_EXP: [makeTransition(/[0-9]/, "HEX_EXP", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
})],
|
||||
NAN_HEX: [makeTransition(/[0-9|A-F|a-f]/, "NAN_HEX", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
})],
|
||||
STOP: []
|
||||
}, "START", "STOP");
|
||||
export function tokenize(input) {
|
||||
var current = 0;
|
||||
var char = input[current]; // Used by SourceLocation
|
||||
|
||||
var column = 1;
|
||||
var line = 1;
|
||||
var tokens = [];
|
||||
/**
|
||||
* Creates a pushToken function for a given type
|
||||
*/
|
||||
|
||||
function pushToken(type) {
|
||||
return function (v) {
|
||||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var startColumn = opts.startColumn || column - String(v).length;
|
||||
delete opts.startColumn;
|
||||
var endColumn = opts.endColumn || startColumn + String(v).length - 1;
|
||||
delete opts.endColumn;
|
||||
var start = {
|
||||
line: line,
|
||||
column: startColumn
|
||||
};
|
||||
var end = {
|
||||
line: line,
|
||||
column: endColumn
|
||||
};
|
||||
tokens.push(Token(type, v, start, end, opts));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Functions to save newly encountered tokens
|
||||
*/
|
||||
|
||||
|
||||
var pushCloseParenToken = pushToken(tokenTypes.closeParen);
|
||||
var pushOpenParenToken = pushToken(tokenTypes.openParen);
|
||||
var pushNumberToken = pushToken(tokenTypes.number);
|
||||
var pushValtypeToken = pushToken(tokenTypes.valtype);
|
||||
var pushNameToken = pushToken(tokenTypes.name);
|
||||
var pushIdentifierToken = pushToken(tokenTypes.identifier);
|
||||
var pushKeywordToken = pushToken(tokenTypes.keyword);
|
||||
var pushDotToken = pushToken(tokenTypes.dot);
|
||||
var pushStringToken = pushToken(tokenTypes.string);
|
||||
var pushCommentToken = pushToken(tokenTypes.comment);
|
||||
var pushEqualToken = pushToken(tokenTypes.equal);
|
||||
/**
|
||||
* Can be used to look at the next character(s).
|
||||
*
|
||||
* The default behavior `lookahead()` simply returns the next character without consuming it.
|
||||
* Letters are always returned in lowercase.
|
||||
*
|
||||
* @param {number} length How many characters to query. Default = 1
|
||||
* @param {number} offset How many characters to skip forward from current one. Default = 1
|
||||
*
|
||||
*/
|
||||
|
||||
function lookahead() {
|
||||
var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
||||
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||
return input.substring(current + offset, current + offset + length).toLowerCase();
|
||||
}
|
||||
/**
|
||||
* Advances the cursor in the input by a certain amount
|
||||
*
|
||||
* @param {number} amount How many characters to consume. Default = 1
|
||||
*/
|
||||
|
||||
|
||||
function eatCharacter() {
|
||||
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
||||
column += amount;
|
||||
current += amount;
|
||||
char = input[current];
|
||||
}
|
||||
|
||||
while (current < input.length) {
|
||||
// ;;
|
||||
if (char === ";" && lookahead() === ";") {
|
||||
var startColumn = column;
|
||||
eatCharacter(2);
|
||||
var text = "";
|
||||
|
||||
while (!isNewLine(char)) {
|
||||
text += char;
|
||||
eatCharacter();
|
||||
|
||||
if (char === undefined) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var endColumn = column;
|
||||
pushCommentToken(text, {
|
||||
type: "leading",
|
||||
startColumn: startColumn,
|
||||
endColumn: endColumn
|
||||
});
|
||||
continue;
|
||||
} // (;
|
||||
|
||||
|
||||
if (char === "(" && lookahead() === ";") {
|
||||
var _startColumn = column;
|
||||
eatCharacter(2);
|
||||
var _text = ""; // ;)
|
||||
|
||||
while (true) {
|
||||
char = input[current];
|
||||
|
||||
if (char === ";" && lookahead() === ")") {
|
||||
eatCharacter(2);
|
||||
break;
|
||||
}
|
||||
|
||||
_text += char;
|
||||
eatCharacter();
|
||||
|
||||
if (isNewLine(char)) {
|
||||
line++;
|
||||
column = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var _endColumn = column;
|
||||
pushCommentToken(_text, {
|
||||
type: "block",
|
||||
startColumn: _startColumn,
|
||||
endColumn: _endColumn
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === "(") {
|
||||
pushOpenParenToken(char);
|
||||
eatCharacter();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === "=") {
|
||||
pushEqualToken(char);
|
||||
eatCharacter();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === ")") {
|
||||
pushCloseParenToken(char);
|
||||
eatCharacter();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isNewLine(char)) {
|
||||
line++;
|
||||
eatCharacter();
|
||||
column = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (WHITESPACE.test(char)) {
|
||||
eatCharacter();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === "$") {
|
||||
var _startColumn2 = column;
|
||||
eatCharacter();
|
||||
var value = "";
|
||||
|
||||
while (idchar.test(char)) {
|
||||
value += char;
|
||||
eatCharacter();
|
||||
}
|
||||
|
||||
var _endColumn2 = column;
|
||||
pushIdentifierToken(value, {
|
||||
startColumn: _startColumn2,
|
||||
endColumn: _endColumn2
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NUMBERS.test(char) || NUMBER_KEYWORDS.test(lookahead(3, 0)) || char === "-" || char === "+") {
|
||||
var _startColumn3 = column;
|
||||
|
||||
var _value = numberLiteralFSM.run(input.slice(current));
|
||||
|
||||
if (_value === "") {
|
||||
throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char));
|
||||
}
|
||||
|
||||
pushNumberToken(_value, {
|
||||
startColumn: _startColumn3
|
||||
});
|
||||
eatCharacter(_value.length);
|
||||
|
||||
if (char && !PARENS.test(char) && !WHITESPACE.test(char)) {
|
||||
throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === '"') {
|
||||
var _startColumn4 = column;
|
||||
var _value2 = "";
|
||||
eatCharacter(); // "
|
||||
|
||||
while (char !== '"') {
|
||||
if (isNewLine(char)) {
|
||||
throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char));
|
||||
}
|
||||
|
||||
_value2 += char;
|
||||
eatCharacter(); // char
|
||||
}
|
||||
|
||||
eatCharacter(); // "
|
||||
|
||||
var _endColumn3 = column;
|
||||
pushStringToken(_value2, {
|
||||
startColumn: _startColumn4,
|
||||
endColumn: _endColumn3
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (LETTERS.test(char)) {
|
||||
var _value3 = "";
|
||||
var _startColumn5 = column;
|
||||
|
||||
while (char && LETTERS.test(char)) {
|
||||
_value3 += char;
|
||||
eatCharacter();
|
||||
}
|
||||
/*
|
||||
* Handle MemberAccess
|
||||
*/
|
||||
|
||||
|
||||
if (char === ".") {
|
||||
var dotStartColumn = column;
|
||||
|
||||
if (valtypes.indexOf(_value3) !== -1) {
|
||||
pushValtypeToken(_value3, {
|
||||
startColumn: _startColumn5
|
||||
});
|
||||
} else {
|
||||
pushNameToken(_value3);
|
||||
}
|
||||
|
||||
eatCharacter();
|
||||
_value3 = "";
|
||||
var nameStartColumn = column;
|
||||
|
||||
while (LETTERS.test(char)) {
|
||||
_value3 += char;
|
||||
eatCharacter();
|
||||
}
|
||||
|
||||
pushDotToken(".", {
|
||||
startColumn: dotStartColumn
|
||||
});
|
||||
pushNameToken(_value3, {
|
||||
startColumn: nameStartColumn
|
||||
});
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Handle keywords
|
||||
*/
|
||||
// $FlowIgnore
|
||||
|
||||
|
||||
if (typeof keywords[_value3] === "string") {
|
||||
pushKeywordToken(_value3, {
|
||||
startColumn: _startColumn5
|
||||
});
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Handle types
|
||||
*/
|
||||
|
||||
|
||||
if (valtypes.indexOf(_value3) !== -1) {
|
||||
pushValtypeToken(_value3, {
|
||||
startColumn: _startColumn5
|
||||
});
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Handle literals
|
||||
*/
|
||||
|
||||
|
||||
pushNameToken(_value3, {
|
||||
startColumn: _startColumn5
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char));
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
export var tokens = tokenTypes;
|
1769
web/node_modules/@webassemblyjs/wast-parser/lib/grammar.js
generated
vendored
Normal file
1769
web/node_modules/@webassemblyjs/wast-parser/lib/grammar.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
35
web/node_modules/@webassemblyjs/wast-parser/lib/index.js
generated
vendored
Normal file
35
web/node_modules/@webassemblyjs/wast-parser/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
parse: true
|
||||
};
|
||||
exports.parse = parse;
|
||||
|
||||
var parser = _interopRequireWildcard(require("./grammar"));
|
||||
|
||||
var _tokenizer = require("./tokenizer");
|
||||
|
||||
var _numberLiterals = require("./number-literals");
|
||||
|
||||
Object.keys(_numberLiterals).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _numberLiterals[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function parse(source) {
|
||||
var tokens = (0, _tokenizer.tokenize)(source); // We pass the source here to show code frames
|
||||
|
||||
var ast = parser.parse(tokens, source);
|
||||
return ast;
|
||||
}
|
116
web/node_modules/@webassemblyjs/wast-parser/lib/number-literals.js
generated
vendored
Normal file
116
web/node_modules/@webassemblyjs/wast-parser/lib/number-literals.js
generated
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.parse32F = parse32F;
|
||||
exports.parse64F = parse64F;
|
||||
exports.parse32I = parse32I;
|
||||
exports.parseU32 = parseU32;
|
||||
exports.parse64I = parse64I;
|
||||
exports.isInfLiteral = isInfLiteral;
|
||||
exports.isNanLiteral = isNanLiteral;
|
||||
|
||||
var _long = _interopRequireDefault(require("@xtuc/long"));
|
||||
|
||||
var _floatingPointHexParser = _interopRequireDefault(require("@webassemblyjs/floating-point-hex-parser"));
|
||||
|
||||
var _helperApiError = require("@webassemblyjs/helper-api-error");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function parse32F(sourceString) {
|
||||
if (isHexLiteral(sourceString)) {
|
||||
return (0, _floatingPointHexParser.default)(sourceString);
|
||||
}
|
||||
|
||||
if (isInfLiteral(sourceString)) {
|
||||
return sourceString[0] === "-" ? -1 : 1;
|
||||
}
|
||||
|
||||
if (isNanLiteral(sourceString)) {
|
||||
return (sourceString[0] === "-" ? -1 : 1) * (sourceString.includes(":") ? parseInt(sourceString.substring(sourceString.indexOf(":") + 1), 16) : 0x400000);
|
||||
}
|
||||
|
||||
return parseFloat(sourceString);
|
||||
}
|
||||
|
||||
function parse64F(sourceString) {
|
||||
if (isHexLiteral(sourceString)) {
|
||||
return (0, _floatingPointHexParser.default)(sourceString);
|
||||
}
|
||||
|
||||
if (isInfLiteral(sourceString)) {
|
||||
return sourceString[0] === "-" ? -1 : 1;
|
||||
}
|
||||
|
||||
if (isNanLiteral(sourceString)) {
|
||||
return (sourceString[0] === "-" ? -1 : 1) * (sourceString.includes(":") ? parseInt(sourceString.substring(sourceString.indexOf(":") + 1), 16) : 0x8000000000000);
|
||||
}
|
||||
|
||||
if (isHexLiteral(sourceString)) {
|
||||
return (0, _floatingPointHexParser.default)(sourceString);
|
||||
}
|
||||
|
||||
return parseFloat(sourceString);
|
||||
}
|
||||
|
||||
function parse32I(sourceString) {
|
||||
var value = 0;
|
||||
|
||||
if (isHexLiteral(sourceString)) {
|
||||
value = ~~parseInt(sourceString, 16);
|
||||
} else if (isDecimalExponentLiteral(sourceString)) {
|
||||
throw new Error("This number literal format is yet to be implemented.");
|
||||
} else {
|
||||
value = parseInt(sourceString, 10);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function parseU32(sourceString) {
|
||||
var value = parse32I(sourceString);
|
||||
|
||||
if (value < 0) {
|
||||
throw new _helperApiError.CompileError("Illegal value for u32: " + sourceString);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function parse64I(sourceString) {
|
||||
var long;
|
||||
|
||||
if (isHexLiteral(sourceString)) {
|
||||
long = _long.default.fromString(sourceString, false, 16);
|
||||
} else if (isDecimalExponentLiteral(sourceString)) {
|
||||
throw new Error("This number literal format is yet to be implemented.");
|
||||
} else {
|
||||
long = _long.default.fromString(sourceString);
|
||||
}
|
||||
|
||||
return {
|
||||
high: long.high,
|
||||
low: long.low
|
||||
};
|
||||
}
|
||||
|
||||
var NAN_WORD = /^\+?-?nan/;
|
||||
var INF_WORD = /^\+?-?inf/;
|
||||
|
||||
function isInfLiteral(sourceString) {
|
||||
return INF_WORD.test(sourceString.toLowerCase());
|
||||
}
|
||||
|
||||
function isNanLiteral(sourceString) {
|
||||
return NAN_WORD.test(sourceString.toLowerCase());
|
||||
}
|
||||
|
||||
function isDecimalExponentLiteral(sourceString) {
|
||||
return !isHexLiteral(sourceString) && sourceString.toUpperCase().includes("E");
|
||||
}
|
||||
|
||||
function isHexLiteral(sourceString) {
|
||||
return sourceString.substring(0, 2).toUpperCase() === "0X" || sourceString.substring(0, 3).toUpperCase() === "-0X";
|
||||
}
|
94
web/node_modules/@webassemblyjs/wast-parser/lib/string-literals.js
generated
vendored
Normal file
94
web/node_modules/@webassemblyjs/wast-parser/lib/string-literals.js
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.parseString = parseString;
|
||||
// string literal characters cannot contain control codes
|
||||
var CONTROL_CODES = [0, // null
|
||||
7, // bell
|
||||
8, // backspace
|
||||
9, // horizontal
|
||||
10, // line feed
|
||||
11, // vertical tab
|
||||
12, // form feed
|
||||
13, // carriage return
|
||||
26, // Control-Z
|
||||
27, // escape
|
||||
127 // delete
|
||||
]; // escaped sequences can either be a two character hex value, or one of the
|
||||
// following single character codes
|
||||
|
||||
function decodeControlCharacter(char) {
|
||||
switch (char) {
|
||||
case "t":
|
||||
return 0x09;
|
||||
|
||||
case "n":
|
||||
return 0x0a;
|
||||
|
||||
case "r":
|
||||
return 0x0d;
|
||||
|
||||
case '"':
|
||||
return 0x22;
|
||||
|
||||
case "′":
|
||||
return 0x27;
|
||||
|
||||
case "\\":
|
||||
return 0x5c;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
var ESCAPE_CHAR = 92; // backslash
|
||||
|
||||
var QUOTE_CHAR = 34; // backslash
|
||||
// parse string as per the spec:
|
||||
// https://webassembly.github.io/spec/core/multipage/text/values.html#text-string
|
||||
|
||||
function parseString(value) {
|
||||
var byteArray = [];
|
||||
var index = 0;
|
||||
|
||||
while (index < value.length) {
|
||||
var charCode = value.charCodeAt(index);
|
||||
|
||||
if (CONTROL_CODES.indexOf(charCode) !== -1) {
|
||||
throw new Error("ASCII control characters are not permitted within string literals");
|
||||
}
|
||||
|
||||
if (charCode === QUOTE_CHAR) {
|
||||
throw new Error("quotes are not permitted within string literals");
|
||||
}
|
||||
|
||||
if (charCode === ESCAPE_CHAR) {
|
||||
var firstChar = value.substr(index + 1, 1);
|
||||
var decodedControlChar = decodeControlCharacter(firstChar);
|
||||
|
||||
if (decodedControlChar !== -1) {
|
||||
// single character escaped values, e.g. \r
|
||||
byteArray.push(decodedControlChar);
|
||||
index += 2;
|
||||
} else {
|
||||
// hex escaped values, e.g. \2a
|
||||
var hexValue = value.substr(index + 1, 2);
|
||||
|
||||
if (!/^[0-9A-F]{2}$/i.test(hexValue)) {
|
||||
throw new Error("invalid character encoding");
|
||||
}
|
||||
|
||||
byteArray.push(parseInt(hexValue, 16));
|
||||
index += 3;
|
||||
}
|
||||
} else {
|
||||
// ASCII encoded values
|
||||
byteArray.push(charCode);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return byteArray;
|
||||
}
|
447
web/node_modules/@webassemblyjs/wast-parser/lib/tokenizer.js
generated
vendored
Normal file
447
web/node_modules/@webassemblyjs/wast-parser/lib/tokenizer.js
generated
vendored
Normal file
|
@ -0,0 +1,447 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.tokenize = tokenize;
|
||||
exports.tokens = exports.keywords = void 0;
|
||||
|
||||
var _helperFsm = require("@webassemblyjs/helper-fsm");
|
||||
|
||||
var _helperCodeFrame = require("@webassemblyjs/helper-code-frame");
|
||||
|
||||
// eslint-disable-next-line
|
||||
function getCodeFrame(source, line, column) {
|
||||
var loc = {
|
||||
start: {
|
||||
line: line,
|
||||
column: column
|
||||
}
|
||||
};
|
||||
return "\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, loc) + "\n";
|
||||
}
|
||||
|
||||
var WHITESPACE = /\s/;
|
||||
var PARENS = /\(|\)/;
|
||||
var LETTERS = /[a-z0-9_/]/i;
|
||||
var idchar = /[a-z0-9!#$%&*+./:<=>?@\\[\]^_`|~-]/i;
|
||||
var valtypes = ["i32", "i64", "f32", "f64"];
|
||||
var NUMBERS = /[0-9|.|_]/;
|
||||
var NUMBER_KEYWORDS = /nan|inf/;
|
||||
|
||||
function isNewLine(char) {
|
||||
return char.charCodeAt(0) === 10 || char.charCodeAt(0) === 13;
|
||||
}
|
||||
|
||||
function Token(type, value, start, end) {
|
||||
var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
||||
var token = {
|
||||
type: type,
|
||||
value: value,
|
||||
loc: {
|
||||
start: start,
|
||||
end: end
|
||||
}
|
||||
};
|
||||
|
||||
if (Object.keys(opts).length > 0) {
|
||||
// $FlowIgnore
|
||||
token["opts"] = opts;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
var tokenTypes = {
|
||||
openParen: "openParen",
|
||||
closeParen: "closeParen",
|
||||
number: "number",
|
||||
string: "string",
|
||||
name: "name",
|
||||
identifier: "identifier",
|
||||
valtype: "valtype",
|
||||
dot: "dot",
|
||||
comment: "comment",
|
||||
equal: "equal",
|
||||
keyword: "keyword"
|
||||
};
|
||||
var keywords = {
|
||||
module: "module",
|
||||
func: "func",
|
||||
param: "param",
|
||||
result: "result",
|
||||
export: "export",
|
||||
loop: "loop",
|
||||
block: "block",
|
||||
if: "if",
|
||||
then: "then",
|
||||
else: "else",
|
||||
call: "call",
|
||||
call_indirect: "call_indirect",
|
||||
import: "import",
|
||||
memory: "memory",
|
||||
table: "table",
|
||||
global: "global",
|
||||
anyfunc: "anyfunc",
|
||||
mut: "mut",
|
||||
data: "data",
|
||||
type: "type",
|
||||
elem: "elem",
|
||||
start: "start",
|
||||
offset: "offset"
|
||||
};
|
||||
exports.keywords = keywords;
|
||||
var NUMERIC_SEPARATOR = "_";
|
||||
/**
|
||||
* Build the FSM for number literals
|
||||
*/
|
||||
|
||||
var numberLiteralFSM = new _helperFsm.FSM({
|
||||
START: [(0, _helperFsm.makeTransition)(/-|\+/, "AFTER_SIGN"), (0, _helperFsm.makeTransition)(/nan:0x/, "NAN_HEX", {
|
||||
n: 6
|
||||
}), (0, _helperFsm.makeTransition)(/nan|inf/, "STOP", {
|
||||
n: 3
|
||||
}), (0, _helperFsm.makeTransition)(/0x/, "HEX", {
|
||||
n: 2
|
||||
}), (0, _helperFsm.makeTransition)(/[0-9]/, "DEC"), (0, _helperFsm.makeTransition)(/\./, "DEC_FRAC")],
|
||||
AFTER_SIGN: [(0, _helperFsm.makeTransition)(/nan:0x/, "NAN_HEX", {
|
||||
n: 6
|
||||
}), (0, _helperFsm.makeTransition)(/nan|inf/, "STOP", {
|
||||
n: 3
|
||||
}), (0, _helperFsm.makeTransition)(/0x/, "HEX", {
|
||||
n: 2
|
||||
}), (0, _helperFsm.makeTransition)(/[0-9]/, "DEC"), (0, _helperFsm.makeTransition)(/\./, "DEC_FRAC")],
|
||||
DEC_FRAC: [(0, _helperFsm.makeTransition)(/[0-9]/, "DEC_FRAC", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
}), (0, _helperFsm.makeTransition)(/e|E/, "DEC_SIGNED_EXP")],
|
||||
DEC: [(0, _helperFsm.makeTransition)(/[0-9]/, "DEC", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
}), (0, _helperFsm.makeTransition)(/\./, "DEC_FRAC"), (0, _helperFsm.makeTransition)(/e|E/, "DEC_SIGNED_EXP")],
|
||||
DEC_SIGNED_EXP: [(0, _helperFsm.makeTransition)(/\+|-/, "DEC_EXP"), (0, _helperFsm.makeTransition)(/[0-9]/, "DEC_EXP")],
|
||||
DEC_EXP: [(0, _helperFsm.makeTransition)(/[0-9]/, "DEC_EXP", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
})],
|
||||
HEX: [(0, _helperFsm.makeTransition)(/[0-9|A-F|a-f]/, "HEX", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
}), (0, _helperFsm.makeTransition)(/\./, "HEX_FRAC"), (0, _helperFsm.makeTransition)(/p|P/, "HEX_SIGNED_EXP")],
|
||||
HEX_FRAC: [(0, _helperFsm.makeTransition)(/[0-9|A-F|a-f]/, "HEX_FRAC", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
}), (0, _helperFsm.makeTransition)(/p|P|/, "HEX_SIGNED_EXP")],
|
||||
HEX_SIGNED_EXP: [(0, _helperFsm.makeTransition)(/[0-9|+|-]/, "HEX_EXP")],
|
||||
HEX_EXP: [(0, _helperFsm.makeTransition)(/[0-9]/, "HEX_EXP", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
})],
|
||||
NAN_HEX: [(0, _helperFsm.makeTransition)(/[0-9|A-F|a-f]/, "NAN_HEX", {
|
||||
allowedSeparator: NUMERIC_SEPARATOR
|
||||
})],
|
||||
STOP: []
|
||||
}, "START", "STOP");
|
||||
|
||||
function tokenize(input) {
|
||||
var current = 0;
|
||||
var char = input[current]; // Used by SourceLocation
|
||||
|
||||
var column = 1;
|
||||
var line = 1;
|
||||
var tokens = [];
|
||||
/**
|
||||
* Creates a pushToken function for a given type
|
||||
*/
|
||||
|
||||
function pushToken(type) {
|
||||
return function (v) {
|
||||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var startColumn = opts.startColumn || column - String(v).length;
|
||||
delete opts.startColumn;
|
||||
var endColumn = opts.endColumn || startColumn + String(v).length - 1;
|
||||
delete opts.endColumn;
|
||||
var start = {
|
||||
line: line,
|
||||
column: startColumn
|
||||
};
|
||||
var end = {
|
||||
line: line,
|
||||
column: endColumn
|
||||
};
|
||||
tokens.push(Token(type, v, start, end, opts));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Functions to save newly encountered tokens
|
||||
*/
|
||||
|
||||
|
||||
var pushCloseParenToken = pushToken(tokenTypes.closeParen);
|
||||
var pushOpenParenToken = pushToken(tokenTypes.openParen);
|
||||
var pushNumberToken = pushToken(tokenTypes.number);
|
||||
var pushValtypeToken = pushToken(tokenTypes.valtype);
|
||||
var pushNameToken = pushToken(tokenTypes.name);
|
||||
var pushIdentifierToken = pushToken(tokenTypes.identifier);
|
||||
var pushKeywordToken = pushToken(tokenTypes.keyword);
|
||||
var pushDotToken = pushToken(tokenTypes.dot);
|
||||
var pushStringToken = pushToken(tokenTypes.string);
|
||||
var pushCommentToken = pushToken(tokenTypes.comment);
|
||||
var pushEqualToken = pushToken(tokenTypes.equal);
|
||||
/**
|
||||
* Can be used to look at the next character(s).
|
||||
*
|
||||
* The default behavior `lookahead()` simply returns the next character without consuming it.
|
||||
* Letters are always returned in lowercase.
|
||||
*
|
||||
* @param {number} length How many characters to query. Default = 1
|
||||
* @param {number} offset How many characters to skip forward from current one. Default = 1
|
||||
*
|
||||
*/
|
||||
|
||||
function lookahead() {
|
||||
var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
||||
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||
return input.substring(current + offset, current + offset + length).toLowerCase();
|
||||
}
|
||||
/**
|
||||
* Advances the cursor in the input by a certain amount
|
||||
*
|
||||
* @param {number} amount How many characters to consume. Default = 1
|
||||
*/
|
||||
|
||||
|
||||
function eatCharacter() {
|
||||
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
||||
column += amount;
|
||||
current += amount;
|
||||
char = input[current];
|
||||
}
|
||||
|
||||
while (current < input.length) {
|
||||
// ;;
|
||||
if (char === ";" && lookahead() === ";") {
|
||||
var startColumn = column;
|
||||
eatCharacter(2);
|
||||
var text = "";
|
||||
|
||||
while (!isNewLine(char)) {
|
||||
text += char;
|
||||
eatCharacter();
|
||||
|
||||
if (char === undefined) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var endColumn = column;
|
||||
pushCommentToken(text, {
|
||||
type: "leading",
|
||||
startColumn: startColumn,
|
||||
endColumn: endColumn
|
||||
});
|
||||
continue;
|
||||
} // (;
|
||||
|
||||
|
||||
if (char === "(" && lookahead() === ";") {
|
||||
var _startColumn = column;
|
||||
eatCharacter(2);
|
||||
var _text = ""; // ;)
|
||||
|
||||
while (true) {
|
||||
char = input[current];
|
||||
|
||||
if (char === ";" && lookahead() === ")") {
|
||||
eatCharacter(2);
|
||||
break;
|
||||
}
|
||||
|
||||
_text += char;
|
||||
eatCharacter();
|
||||
|
||||
if (isNewLine(char)) {
|
||||
line++;
|
||||
column = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var _endColumn = column;
|
||||
pushCommentToken(_text, {
|
||||
type: "block",
|
||||
startColumn: _startColumn,
|
||||
endColumn: _endColumn
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === "(") {
|
||||
pushOpenParenToken(char);
|
||||
eatCharacter();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === "=") {
|
||||
pushEqualToken(char);
|
||||
eatCharacter();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === ")") {
|
||||
pushCloseParenToken(char);
|
||||
eatCharacter();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isNewLine(char)) {
|
||||
line++;
|
||||
eatCharacter();
|
||||
column = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (WHITESPACE.test(char)) {
|
||||
eatCharacter();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === "$") {
|
||||
var _startColumn2 = column;
|
||||
eatCharacter();
|
||||
var value = "";
|
||||
|
||||
while (idchar.test(char)) {
|
||||
value += char;
|
||||
eatCharacter();
|
||||
}
|
||||
|
||||
var _endColumn2 = column;
|
||||
pushIdentifierToken(value, {
|
||||
startColumn: _startColumn2,
|
||||
endColumn: _endColumn2
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NUMBERS.test(char) || NUMBER_KEYWORDS.test(lookahead(3, 0)) || char === "-" || char === "+") {
|
||||
var _startColumn3 = column;
|
||||
|
||||
var _value = numberLiteralFSM.run(input.slice(current));
|
||||
|
||||
if (_value === "") {
|
||||
throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char));
|
||||
}
|
||||
|
||||
pushNumberToken(_value, {
|
||||
startColumn: _startColumn3
|
||||
});
|
||||
eatCharacter(_value.length);
|
||||
|
||||
if (char && !PARENS.test(char) && !WHITESPACE.test(char)) {
|
||||
throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === '"') {
|
||||
var _startColumn4 = column;
|
||||
var _value2 = "";
|
||||
eatCharacter(); // "
|
||||
|
||||
while (char !== '"') {
|
||||
if (isNewLine(char)) {
|
||||
throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char));
|
||||
}
|
||||
|
||||
_value2 += char;
|
||||
eatCharacter(); // char
|
||||
}
|
||||
|
||||
eatCharacter(); // "
|
||||
|
||||
var _endColumn3 = column;
|
||||
pushStringToken(_value2, {
|
||||
startColumn: _startColumn4,
|
||||
endColumn: _endColumn3
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (LETTERS.test(char)) {
|
||||
var _value3 = "";
|
||||
var _startColumn5 = column;
|
||||
|
||||
while (char && LETTERS.test(char)) {
|
||||
_value3 += char;
|
||||
eatCharacter();
|
||||
}
|
||||
/*
|
||||
* Handle MemberAccess
|
||||
*/
|
||||
|
||||
|
||||
if (char === ".") {
|
||||
var dotStartColumn = column;
|
||||
|
||||
if (valtypes.indexOf(_value3) !== -1) {
|
||||
pushValtypeToken(_value3, {
|
||||
startColumn: _startColumn5
|
||||
});
|
||||
} else {
|
||||
pushNameToken(_value3);
|
||||
}
|
||||
|
||||
eatCharacter();
|
||||
_value3 = "";
|
||||
var nameStartColumn = column;
|
||||
|
||||
while (LETTERS.test(char)) {
|
||||
_value3 += char;
|
||||
eatCharacter();
|
||||
}
|
||||
|
||||
pushDotToken(".", {
|
||||
startColumn: dotStartColumn
|
||||
});
|
||||
pushNameToken(_value3, {
|
||||
startColumn: nameStartColumn
|
||||
});
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Handle keywords
|
||||
*/
|
||||
// $FlowIgnore
|
||||
|
||||
|
||||
if (typeof keywords[_value3] === "string") {
|
||||
pushKeywordToken(_value3, {
|
||||
startColumn: _startColumn5
|
||||
});
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Handle types
|
||||
*/
|
||||
|
||||
|
||||
if (valtypes.indexOf(_value3) !== -1) {
|
||||
pushValtypeToken(_value3, {
|
||||
startColumn: _startColumn5
|
||||
});
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Handle literals
|
||||
*/
|
||||
|
||||
|
||||
pushNameToken(_value3, {
|
||||
startColumn: _startColumn5
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char));
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
var tokens = tokenTypes;
|
||||
exports.tokens = tokens;
|
40
web/node_modules/@webassemblyjs/wast-parser/package.json
generated
vendored
Normal file
40
web/node_modules/@webassemblyjs/wast-parser/package.json
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "@webassemblyjs/wast-parser",
|
||||
"version": "1.9.0",
|
||||
"description": "WebAssembly text format parser",
|
||||
"keywords": [
|
||||
"webassembly",
|
||||
"javascript",
|
||||
"ast",
|
||||
"parser",
|
||||
"wat",
|
||||
"wast"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"module": "esm/index.js",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"author": "Sven Sauleau",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@webassemblyjs/ast": "1.9.0",
|
||||
"@webassemblyjs/floating-point-hex-parser": "1.9.0",
|
||||
"@webassemblyjs/helper-api-error": "1.9.0",
|
||||
"@webassemblyjs/helper-code-frame": "1.9.0",
|
||||
"@webassemblyjs/helper-fsm": "1.9.0",
|
||||
"@xtuc/long": "4.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@webassemblyjs/helper-test-framework": "1.9.0",
|
||||
"mamacro": "^0.0.7"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/xtuc/webassemblyjs.git"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "0440b420888c1f7701eb9762ec657775506b87d8"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue