Comparing version 1.0.1 to 1.0.2-dev.20190628
@@ -53,4 +53,4 @@ import { Token } from './token'; | ||
None = 0, | ||
Variable = 1, | ||
ArgList = 2, | ||
ArgList = 1, | ||
Variable = 4, | ||
Let = 8, | ||
@@ -57,0 +57,0 @@ Const = 16 |
@@ -10,3 +10,2 @@ import { ParserState } from '../common'; | ||
export declare function consumeMultiUnitCodePoint(parser: ParserState, hi: number): boolean; | ||
export declare function storeRaw(parser: ParserState, start: number): void; | ||
export declare function consumeLineFeed(parser: ParserState, lastIsCR: boolean): void; | ||
@@ -13,0 +12,0 @@ export declare function advanceNewline(parser: ParserState): void; |
export { scanSingleToken, nextToken } from './scan'; | ||
export { skipMultiLineComment, skipSingleLineComment, skipHashBang } from './comments'; | ||
export { nextCP, consumeMultiUnitCodePoint, isExoticECMAScriptWhitespace, fromCodePoint, toHex, storeRaw, consumeLineFeed, advanceNewline, LexerState } from './common'; | ||
export { nextCP, consumeMultiUnitCodePoint, isExoticECMAScriptWhitespace, fromCodePoint, toHex, consumeLineFeed, advanceNewline, LexerState } from './common'; | ||
export { CharTypes, CharFlags, isIdentifierStart, isIdentifierPart } from './charClassifier'; | ||
@@ -5,0 +5,0 @@ export { scanIdentifier, scanIdentifierSlowCase, scanUnicodeIdentifier, scanPrivateName, scanUnicodeEscapeValue } from './identifier'; |
@@ -49,3 +49,3 @@ import { Token } from './token'; | ||
export declare function parseVariableStatement(parser: ParserState, context: Context, scope: ScopeState, origin: BindingOrigin, start: number, line: number, column: number): ESTree.VariableDeclaration; | ||
export declare function parseVariableDeclarationList(parser: ParserState, context: Context, scope: ScopeState, verifyDuplicates: 0 | 1, isVarDecl: 0 | 1, type: BindingType, origin: BindingOrigin): ESTree.VariableDeclarator[]; | ||
export declare function parseVariableDeclarationList(parser: ParserState, context: Context, scope: ScopeState, verifyDuplicates: 0 | 1, type: BindingType, origin: BindingOrigin): ESTree.VariableDeclarator[]; | ||
export declare function parseForStatement(parser: ParserState, context: Context, scope: ScopeState, labels: any, start: number, line: number, column: number): ESTree.ForStatement | ESTree.ForInStatement | ESTree.ForOfStatement; | ||
@@ -99,3 +99,3 @@ export declare function parseExpression(parser: ParserState, context: Context, assignable: 0 | 1, inGroup: 0 | 1, start: number, line: number, column: number): ESTree.Expression; | ||
export declare function parseFieldDefinition(parser: ParserState, context: Context, key: ESTree.PrivateName | ESTree.Expression | null, state: PropertyKind, decorators: ESTree.Decorator[] | null, start: number, line: number, column: number): ESTree.FieldDefinition; | ||
export declare function parseBindingPattern(parser: ParserState, context: Context, scope: any, dupeChecks: 0 | 1, isVarDecl: 0 | 1, type: BindingType, origin: BindingOrigin, start: number, line: number, column: number): ESTree.Pattern | ESTree.Identifier; | ||
export declare function parseBindingPattern(parser: ParserState, context: Context, scope: any, dupeChecks: 0 | 1, type: BindingType, origin: BindingOrigin, start: number, line: number, column: number): ESTree.Pattern | ESTree.Identifier; | ||
//# sourceMappingURL=parser.d.ts.map |
@@ -0,0 +0,0 @@ ISC License |
{ | ||
"name": "meriyah", | ||
"version": "1.0.1", | ||
"version": "1.0.2-dev.20190628", | ||
"description": "A 100% compliant, self-hosted javascript parser with high focus on both performance and stability", | ||
@@ -92,2 +92,2 @@ "main": "dist/meriyah.umd.js", | ||
} | ||
} | ||
} |
@@ -0,0 +0,0 @@ # Meriyah |
@@ -61,4 +61,4 @@ import { Token, KeywordDescTable } from './token'; | ||
None = 0, | ||
Variable = 1 << 0, | ||
ArgList = 1 << 1, | ||
ArgList = 1 << 0, | ||
Variable = 1 << 2, | ||
Let = 1 << 3, | ||
@@ -65,0 +65,0 @@ Const = 1 << 4 |
@@ -31,3 +31,2 @@ import { ParserState } from './common'; | ||
CantAssignToAsyncArrow, | ||
CantAssignToValidRHS, | ||
SuperNoConstructor, | ||
@@ -159,3 +158,4 @@ InvalidSuperProperty, | ||
UnexpectedPrivateField, | ||
DuplicateLetConstBinding | ||
DuplicateLetConstBinding, | ||
CantAssignToValidRHS | ||
} | ||
@@ -178,2 +178,3 @@ | ||
[Errors.ExpectedNumberInRadix]: 'Expected number in radix %0', | ||
[Errors.CantAssignToValidRHS]: 'Invalid left-hand side assignment to a destructible right-hand side', | ||
[Errors.MissingExponent]: 'Non-number found after exponent indicator', | ||
@@ -195,3 +196,2 @@ [Errors.InvalidBigInt]: 'Invalid BigIntLiteral', | ||
[Errors.CantAssignToAsyncArrow]: 'Invalid left-hand side in async arrow', | ||
[Errors.CantAssignToValidRHS]: 'Invalid left-hand side assignment to a destructible right-hand side', | ||
[Errors.SuperNoConstructor]: | ||
@@ -338,6 +338,5 @@ 'Calls to super must be in the "constructor" method of a class expression or class declaration that has a superclass', | ||
constructor(startindex: number, line: number, column: number, type: Errors, ...params: string[]) { | ||
let message = | ||
const message = | ||
'[' + line + ':' + column + ']: ' + errorMessages[type].replace(/%(\d+)/g, (_: string, i: number) => params[i]); | ||
super(`${message}`); | ||
this.index = startindex; | ||
@@ -344,0 +343,0 @@ this.line = line; |
@@ -37,6 +37,2 @@ import { Chars } from '../chars'; | ||
export function storeRaw(parser: ParserState, start: number) { | ||
parser.tokenRaw = parser.source.slice(start, parser.index); | ||
} | ||
/** | ||
@@ -43,0 +39,0 @@ * Use to consume a line feed instead of `advanceNewline`. |
@@ -20,3 +20,3 @@ import { ParserState, Context } from '../common'; | ||
const hasEscape = CharTypes[parser.nextCP] & CharFlags.BackSlash; | ||
if ((parser.nextCP & ~0x7f) === 0 && !hasEscape) { | ||
if (!hasEscape && parser.nextCP < 0x7e) { | ||
return descKeywordTable[parser.tokenValue] || Token.Identifier; | ||
@@ -136,3 +136,2 @@ } | ||
let codePoint = 0; | ||
// First handle a delimited Unicode escape, e.g. \u{1F4A9} | ||
@@ -139,0 +138,0 @@ if (parser.nextCP === Chars.LeftBrace) { |
@@ -9,3 +9,2 @@ export { scanSingleToken, nextToken } from './scan'; | ||
toHex, | ||
storeRaw, | ||
consumeLineFeed, | ||
@@ -12,0 +11,0 @@ advanceNewline, |
import { ParserState, Context, Flags } from '../common'; | ||
import { Token } from '../token'; | ||
import { nextCP, toHex, CharTypes, CharFlags, isIdentifierStart, storeRaw } from './'; | ||
import { nextCP, toHex, CharTypes, CharFlags, isIdentifierStart } from './'; | ||
import { Chars } from '../chars'; | ||
@@ -139,22 +139,18 @@ import { report, Errors } from '../errors'; | ||
// not be an identifier start or a decimal digit | ||
if ((parser.index < parser.end && CharTypes[parser.nextCP] & CharFlags.Decimal) || isIdentifierStart(parser.nextCP)) { | ||
if (CharTypes[parser.nextCP] & CharFlags.Decimal || isIdentifierStart(parser.nextCP)) { | ||
report(parser, Errors.IDStartAfterNumber); | ||
} | ||
if (context & Context.OptionsRaw) parser.tokenRaw = parser.source.slice(parser.tokenIndex, parser.index); | ||
parser.tokenValue = | ||
kind & (NumberKind.ImplicitOctal | NumberKind.Binary | NumberKind.Hex | NumberKind.Octal) | ||
? value | ||
: kind & NumberKind.DecimalWithLeadingZero | ||
? parseFloat(parser.source.slice(parser.tokenIndex, parser.index)) | ||
: isBigInt | ||
? parseInt(parser.source.slice(parser.tokenIndex, parser.index), 0xa) | ||
: +parser.source.slice(parser.tokenIndex, parser.index); | ||
if (kind & (NumberKind.ImplicitOctal | NumberKind.Binary | NumberKind.Hex | NumberKind.Octal)) { | ||
parser.tokenValue = value; | ||
} else { | ||
const raw = parser.source.slice(parser.tokenIndex, parser.index); | ||
parser.tokenValue = | ||
kind & NumberKind.DecimalWithLeadingZero ? parseFloat(raw) : isBigInt ? parseInt(raw, 0xa) : +raw; | ||
} | ||
if (context & Context.OptionsRaw || isBigInt) parser.tokenRaw = parser.source.slice(parser.tokenIndex, parser.index); | ||
if (isBigInt) { | ||
storeRaw(parser, parser.tokenIndex); | ||
return Token.BigIntLiteral; | ||
} | ||
if (context & Context.OptionsRaw) storeRaw(parser, parser.tokenIndex); | ||
return Token.NumericLiteral; | ||
return isBigInt ? Token.BigIntLiteral : Token.NumericLiteral; | ||
} |
@@ -214,3 +214,3 @@ import { skipSingleLineComment, skipMultiLineComment, LexerState } from './'; | ||
// Skip over non-EOL whitespace chars | ||
// Skip over non-EOL whitespace chars. | ||
case Token.WhiteSpace: | ||
@@ -238,3 +238,3 @@ nextCP(parser); | ||
// Look for a string or a template string. | ||
// Look for a string or a template string | ||
case Token.StringLiteral: | ||
@@ -246,3 +246,2 @@ return scanString(parser, context); | ||
// Escaped identifiers | ||
case Token.EscapedIdentifier: | ||
@@ -272,23 +271,2 @@ return scanUnicodeIdentifier(parser, context); | ||
// `=`, `==`, `===`, `=>` | ||
case Token.Assign: { | ||
nextCP(parser); | ||
if (parser.index >= parser.end) return Token.Assign; | ||
const next = parser.nextCP; | ||
if (next === Chars.EqualSign) { | ||
if (nextCP(parser) === Chars.EqualSign) { | ||
nextCP(parser); | ||
return Token.StrictEqual; | ||
} else { | ||
return Token.LooseEqual; | ||
} | ||
} else if (next === Chars.GreaterThan) { | ||
nextCP(parser); | ||
return Token.Arrow; | ||
} | ||
return Token.Assign; | ||
} | ||
// `*`, `**`, `*=`, `**=` | ||
@@ -395,3 +373,4 @@ case Token.Multiply: { | ||
case Chars.LessThan: | ||
if (nextCP(parser) === Chars.EqualSign) { | ||
nextCP(parser); | ||
if ((parser.nextCP as number) === Chars.EqualSign) { | ||
nextCP(parser); | ||
@@ -408,2 +387,3 @@ return Token.ShiftLeftAssign; | ||
case Chars.Exclamation: | ||
// Treat HTML begin-comment as comment-till-end-of-line. | ||
if ( | ||
@@ -423,2 +403,24 @@ (context & Context.Module) === 0 && | ||
// `=`, `==`, `===`, `=>` | ||
case Token.Assign: { | ||
nextCP(parser); | ||
if (parser.index >= parser.end) return Token.Assign; | ||
const next = parser.nextCP; | ||
if (next === Chars.EqualSign) { | ||
nextCP(parser); | ||
if (parser.nextCP === Chars.EqualSign) { | ||
nextCP(parser); | ||
return Token.StrictEqual; | ||
} else { | ||
return Token.LooseEqual; | ||
} | ||
} else if (next === Chars.GreaterThan) { | ||
nextCP(parser); | ||
return Token.Arrow; | ||
} | ||
return Token.Assign; | ||
} | ||
// `|`, `||`, `|=` | ||
@@ -459,3 +461,4 @@ case Token.BitwiseOr: { | ||
if (next === Chars.GreaterThan) { | ||
if (nextCP(parser) === Chars.EqualSign) { | ||
nextCP(parser); | ||
if (parser.nextCP === Chars.EqualSign) { | ||
nextCP(parser); | ||
@@ -509,4 +512,2 @@ return Token.LogicalShiftRightAssign; | ||
} else { | ||
// Non-ASCII code points can only be identifiers or whitespace. | ||
if ((first ^ Chars.LineSeparator) <= 1) { | ||
@@ -513,0 +514,0 @@ state = (state | LexerState.LastIsCR | LexerState.NewLine) ^ LexerState.LastIsCR; |
@@ -5,3 +5,3 @@ import { ParserState, Context, Flags } from '../common'; | ||
import { report, Errors } from '../errors'; | ||
import { toHex, nextCP, fromCodePoint, CharTypes, CharFlags, storeRaw } from './'; | ||
import { toHex, nextCP, fromCodePoint, CharTypes, CharFlags } from './'; | ||
@@ -30,3 +30,3 @@ // Intentionally negative | ||
nextCP(parser); // skip closing quote | ||
if (context & Context.OptionsRaw) storeRaw(parser, start); | ||
if (context & Context.OptionsRaw) parser.tokenRaw = parser.source.slice(start, parser.index); | ||
parser.tokenValue = ret; | ||
@@ -33,0 +33,0 @@ return Token.StringLiteral; |
@@ -0,0 +0,0 @@ import { Context } from './common'; |
@@ -177,8 +177,8 @@ export const enum Token { | ||
PrivateName = 121 | IsIdentifier, | ||
PrivateName = 121 | IsIdentifier, | ||
BigIntLiteral = 122, | ||
WhiteSpace = 124, | ||
WhiteSpace = 124, | ||
Illegal = 129, | ||
CarriageReturn = 130, | ||
PrivateField = 131, | ||
PrivateField = 131, | ||
Template = 132, | ||
@@ -188,3 +188,3 @@ Decorator = 133, | ||
LineFeed = 135, | ||
EscapedIdentifier = 136, | ||
EscapedIdentifier = 136, | ||
} | ||
@@ -191,0 +191,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
2567560
47129
1