Skip to content

Commit

Permalink
fix(lexer): fixed CRLF issues - #46
Browse files Browse the repository at this point in the history
  • Loading branch information
KFlash committed Oct 2, 2019
1 parent e42b676 commit 43bc755
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meriyah",
"version": "1.8.0",
"version": "1.8.2",
"description": "A 100% compliant, self-hosted javascript parser with high focus on both performance and stability",
"main": "dist/meriyah.umd.js",
"module": "dist/meriyah.esm.js",
Expand Down
11 changes: 8 additions & 3 deletions src/lexer/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export const enum NumberKind {
*/
export function advanceChar(parser: ParserState): number {
parser.column++;
return advanceAndLawrenceDolTheCRLF(parser);
}

export function advanceAndLawrenceDolTheCRLF(parser: ParserState) {
parser.currentChar = parser.source.charCodeAt(++parser.index);
if (parser.index < parser.end) {
const cur = parser.currentChar;
const nxt = parser.source.charCodeAt(parser.index + 1);
Expand All @@ -41,7 +46,7 @@ export function advanceChar(parser: ParserState): number {
parser.currentChar = Chars.LineFeed;
}
}
return (parser.currentChar = parser.source.charCodeAt(++parser.index));
return parser.currentChar;
}

/**
Expand All @@ -68,7 +73,7 @@ export function consumeMultiUnitCodePoint(parser: ParserState, hi: number): 0 |
* Use to consume a line feed instead of `consumeLineBreak`.
*/
export function consumeLineFeed(parser: ParserState, state: LexerState): void {
parser.currentChar = parser.source.charCodeAt(++parser.index);
advanceAndLawrenceDolTheCRLF(parser);
parser.flags |= Flags.NewLine;
if ((state & LexerState.LastIsCR) === 0) {
parser.column = 0;
Expand All @@ -80,7 +85,7 @@ export function consumeLineBreak(parser: ParserState): void {
parser.flags |= Flags.NewLine;
parser.column = 0;
parser.line++;
parser.currentChar = parser.source.charCodeAt(++parser.index);
advanceAndLawrenceDolTheCRLF(parser);
}

// ECMA-262 11.2 White Space
Expand Down
2 changes: 1 addition & 1 deletion src/meriyah.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export function parse(source: string, options?: Options): ESTree.Program {
export { Options, ESTree };

// Current version
export const version = '1.8.0';
export const version = '1.8.2';

0 comments on commit 43bc755

Please sign in to comment.