diff --git a/dist/cli-cjs.js b/dist/cli-cjs.js index 151712809..b90d0a09d 100644 --- a/dist/cli-cjs.js +++ b/dist/cli-cjs.js @@ -1183,6 +1183,7 @@ function prettyPrintAST(ast, options) { function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: + console.error("checkActionBlock", {src, yylloc, options}) if (yylloc && yylloc.first_line > 0) { let cnt = yylloc.first_line; let lines = new Array(cnt); @@ -3966,6 +3967,7 @@ case 61: var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + console.error("lexer 3970: arrow action", srcCode) // add braces around ARROW_ACTION_CODE so that the action chunk test/compiler // will uncover any illegal action code following the arrow operator, e.g. // multiple statements separated by semicolon. @@ -22181,7 +22183,7 @@ case 116: this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - + console.error("arrow action 22187:", yyvstack[yysp]) this.$ = '$$ = (' + yyvstack[yysp] + ');'; break; @@ -27345,18 +27347,21 @@ var lexer$2 = function() { /*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: ->.* */ yy_.yytext = yy_.yytext.substr(2, yy_.yyleng - 2).trim(); + console.error("lexer recognized arrow action:", yy_.yytext) return 38; case 70: /*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: →.* */ yy_.yytext = yy_.yytext.substr(1, yy_.yyleng - 1).trim(); + console.error("lexer recognized arrow action:", yy_.yytext) return 38; case 71: /*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: =>.* */ yy_.yytext = yy_.yytext.substr(2, yy_.yyleng - 2).trim(); + console.error("lexer recognized arrow action:", yy_.yytext) return 38; case 72: diff --git a/packages/ebnf-parser/bnf.y b/packages/ebnf-parser/bnf.y index 4d5544216..c942e3a5a 100644 --- a/packages/ebnf-parser/bnf.y +++ b/packages/ebnf-parser/bnf.y @@ -876,7 +876,7 @@ action // add braces around ARROW_ACTION so that the action chunk test/compiler // will uncover any illegal action code following the arrow operator, e.g. // multiple statements separated by semicolon. - { $$ = '$$ = (' + $ARROW_ACTION + ');'; } + { $$ = '$$ = (\n' + $ARROW_ACTION + '\n);'; } | %epsilon { $$ = ''; } ; diff --git a/packages/ebnf-parser/parser.js b/packages/ebnf-parser/parser.js index 7ed930108..621f9018d 100644 --- a/packages/ebnf-parser/parser.js +++ b/packages/ebnf-parser/parser.js @@ -4798,7 +4798,7 @@ let esp = recoveringErrorInfo.info_stack_pointer; // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, 'Line 1048'); + ASSERT(recovering > 0, 'Line 4801'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match @@ -4961,9 +4961,9 @@ r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, 'Line 1204'); - ASSERT(symbol === TERROR, 'Line 1205'); - ASSERT(!action, 'Line 1206'); + ASSERT(recoveringErrorInfo, 'Line 4964'); + ASSERT(symbol === TERROR, 'Line 4965'); + ASSERT(!action, 'Line 4966'); let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack @@ -5012,7 +5012,7 @@ r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); - ASSERT(recoveringErrorInfo, 'Line 1248'); + ASSERT(recoveringErrorInfo, 'Line 5015'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -5055,12 +5055,12 @@ switch (action) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, 'Line 1305'); + ASSERT(recoveringErrorInfo, 'Line 5058'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, 'Line 1309'); - ASSERT(preErrorSymbol === 0, 'Line 1310'); + ASSERT(symbol !== 0, 'Line 5062'); + ASSERT(preErrorSymbol === 0, 'Line 5063'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -5110,7 +5110,7 @@ switch (action) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, 'Line 1352'); + ASSERT(recovering > 0, 'Line 5113'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -5157,7 +5157,7 @@ switch (action) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, 'Line 1383'); + ASSERT(preErrorSymbol === 0, 'Line 5160'); if (recovering === 0) { break; } @@ -5291,7 +5291,7 @@ r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, 'Line 1509'); + ASSERT(action !== 2, 'Line 5294'); if (!action || action === 1) { continue; } @@ -5353,8 +5353,8 @@ switch (action) { symbol = 0; - ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 5356'); // normal execution / no error + ASSERT(recovering === 0, 'Line 5357'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -5365,8 +5365,8 @@ switch (action) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 5368'); // normal execution / no error + ASSERT(recovering === 0, 'Line 5369'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1];