diff --git a/Makefile b/Makefile index 67346380b..baf351897 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,9 @@ MOCHA = node_modules/.bin/mocha NYC = node_modules/.bin/nyc --clean=false --temp-directory ./.nyc_output ifndef FULL_CODE_COVERAGE - JISON = node dist/cli-cjs-es5.js + JISON = node dist/cli-cjs.js else - JISON = $(NYC) --reporter=lcov -- node dist/cli-cjs-es5.js + JISON = $(NYC) --reporter=lcov -- node dist/cli-cjs.js endif @@ -448,7 +448,7 @@ examples/yacc-error-recovery: build build: \ subpackages-build \ prep_util_dir \ - dist/cli-cjs-es5.js \ + dist/cli-cjs.js \ packages/ebnf-parser/ebnf.y \ packages/ebnf-parser/bnf.y \ packages/ebnf-parser/bnf.l \ @@ -464,11 +464,11 @@ npm-update: subpackages-npm-update prep_util_dir: #@[ -d node_modules/jison-gho/dist ] || echo "### FAILURE: Make sure you have run 'make prep' before as the jison compiler backup utility files are unavailable! ###" - #@[ -f node_modules/jison-gho/dist/cli-cjs-es5.js ] || echo "### FAILURE: Make sure you have run 'make prep' before as the jison compiler backup utility files are unavailable! ###" + #@[ -f node_modules/jison-gho/dist/cli-cjs.js ] || echo "### FAILURE: Make sure you have run 'make prep' before as the jison compiler backup utility files are unavailable! ###" -mkdir -p dist - #+[ -f dist/cli-cjs-es5.js ] || ( cp node_modules/jison-gho/dist/cli-cjs-es5.js dist/cli-cjs-es5.js && touch -d 1970/1/1 dist/cli-cjs-es5.js ) + #+[ -f dist/cli-cjs.js ] || ( cp node_modules/jison-gho/dist/cli-cjs.js dist/cli-cjs.js && touch -d 1970/1/1 dist/cli-cjs.js ) -dist/cli-cjs-es5.js: dist/jison.js rollup.config-cli.js package.json lib/jison-parser-kernel.js +dist/cli-cjs.js: dist/jison.js rollup.config-cli.js package.json lib/jison-parser-kernel.js node __patch_version_in_js.js node __patch_parser_kernel_in_js.js -mkdir -p dist diff --git a/dist/cli-cjs-es5.js b/dist/cli-cjs-es5.js index d2c67dfae..45a4659e6 100644 --- a/dist/cli-cjs-es5.js +++ b/dist/cli-cjs-es5.js @@ -3,9 +3,29 @@ 'use strict'; -function _templateObject163() { +function _templateObject165() { var data = _taggedTemplateLiteral(["\n Specify the kind of default action that jison should include for every parser rule.\n\n You can specify a mode for *value handling* (\"$$\") and one for *location tracking* (\"@$\"), separated by a comma, e.g.:\n --default-action=ast,none\n\n Supported value modes:\n - classic : generate a parser which includes the default\n $$ = $1;\n action for every rule.\n - ast : generate a parser which produces a simple AST-like tree-of-arrays structure: every rule produces an array of its production terms' values. Otherwise it is identical to \"classic\" mode.\n - none : JISON will produce a slightly faster parser but then you are solely responsible for propagating rule action \"$$\" results. The default rule value is still deterministic though as it is set to \"undefined\": \"$$ = undefined;\"\n - skip : same as \"none\" mode, except JISON does NOT INJECT a default value action ANYWHERE, hence rule results are not deterministic when you do not properly manage the \"$$\" value yourself!\n\n Supported location modes:\n - merge : generate a parser which includes the default \"@$ = merged(@1..@n);\" location tracking action for every rule, i.e. the rule's production 'location' is the range spanning its terms.\n - classic : same as \"merge\" mode.\n - ast : ditto.\n - none : JISON will produce a slightly faster parser but then you are solely responsible for propagating rule action \"@$\" location results. The default rule location is still deterministic though, as it is set to \"undefined\": \"@$ = undefined;\"\n - skip : same as \"none\" mode, except JISON does NOT INJECT a default location action ANYWHERE, hence rule location results are not deterministic when you do not properly manage the \"@$\" value yourself!\n\n Notes:\n - when you do specify a value default mode, but DO NOT specify a location value mode, the latter is assumed to be the same as the former. Hence:\n --default-action=ast\n equals:\n --default-action=ast,ast\n - when you do not specify an explicit default mode or only a \"true\"/\"1\" value, the default is assumed: \"", "\".\n - when you specify \"false\"/\"0\" as an explicit default mode, \"none,none\" is assumed. This produces the fastest deterministic parser.\n "], ["\n Specify the kind of default action that jison should include for every parser rule.\n\n You can specify a mode for *value handling* (\"$$\") and one for *location tracking* (\"@$\"), separated by a comma, e.g.:\n --default-action=ast,none\n\n Supported value modes:\n - classic : generate a parser which includes the default\n $$ = $1;\n action for every rule.\n - ast : generate a parser which produces a simple AST-like tree-of-arrays structure: every rule produces an array of its production terms' values. Otherwise it is identical to \"classic\" mode.\n - none : JISON will produce a slightly faster parser but then you are solely responsible for propagating rule action \"$$\" results. The default rule value is still deterministic though as it is set to \"undefined\": \"$$ = undefined;\"\n - skip : same as \"none\" mode, except JISON does NOT INJECT a default value action ANYWHERE, hence rule results are not deterministic when you do not properly manage the \"$$\" value yourself!\n\n Supported location modes:\n - merge : generate a parser which includes the default \"@$ = merged(@1..@n);\" location tracking action for every rule, i.e. the rule\\'s production \\'location\\' is the range spanning its terms.\n - classic : same as \"merge\" mode.\n - ast : ditto.\n - none : JISON will produce a slightly faster parser but then you are solely responsible for propagating rule action \"@$\" location results. The default rule location is still deterministic though, as it is set to \"undefined\": \"@$ = undefined;\"\n - skip : same as \"none\" mode, except JISON does NOT INJECT a default location action ANYWHERE, hence rule location results are not deterministic when you do not properly manage the \"@$\" value yourself!\n\n Notes:\n - when you do specify a value default mode, but DO NOT specify a location value mode, the latter is assumed to be the same as the former. Hence:\n --default-action=ast\n equals:\n --default-action=ast,ast\n - when you do not specify an explicit default mode or only a \"true\"/\"1\" value, the default is assumed: \"", "\".\n - when you specify \"false\"/\"0\" as an explicit default mode, \"none,none\" is assumed. This produces the fastest deterministic parser.\n "]); + _templateObject165 = function _templateObject165() { + return data; + }; + + return data; +} + +function _templateObject164() { + var data = _taggedTemplateLiteral(["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the `eval()` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "], ["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the \\`eval()\\` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "]); + + _templateObject164 = function _templateObject164() { + return data; + }; + + return data; +} + +function _templateObject163() { + var data = _taggedTemplateLiteral(["\n\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.parser = ", ";\n exports.Parser = ", ".Parser;\n exports.parse = function () {\n return ", ".parse.apply(", ", arguments);\n };\n ", "\n }\n "]); + _templateObject163 = function _templateObject163() { return data; }; @@ -14,7 +34,7 @@ function _templateObject163() { } function _templateObject162() { - var data = _taggedTemplateLiteral(["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the `eval()` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "], ["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the \\`eval()\\` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "]); + var data = _taggedTemplateLiteral(["\n\n ", "\n\n exports.main = ", ";\n\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n exports.main(process.argv.slice(1));\n }\n "]); _templateObject162 = function _templateObject162() { return data; @@ -24,7 +44,7 @@ function _templateObject162() { } function _templateObject161() { - var data = _taggedTemplateLiteral(["\n\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.parser = ", ";\n exports.Parser = ", ".Parser;\n exports.parse = function () {\n return ", ".parse.apply(", ", arguments);\n };\n ", "\n }\n "]); + var data = _taggedTemplateLiteral(["\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser;\n parser.Parser = Parser;\n\n function yyparse() {\n return parser.parse.apply(parser, arguments);\n }\n\n ", "\n\n export default {\n parser,\n Parser,\n parse: yyparse,\n ", "\n };\n "]); _templateObject161 = function _templateObject161() { return data; @@ -34,7 +54,7 @@ function _templateObject161() { } function _templateObject160() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n exports.main = ", ";\n\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n exports.main(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n yyExecMain();\n }\n "]); _templateObject160 = function _templateObject160() { return data; @@ -44,7 +64,7 @@ function _templateObject160() { } function _templateObject159() { - var data = _taggedTemplateLiteral(["\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser;\n parser.Parser = Parser;\n\n function yyparse() {\n return parser.parse.apply(parser, arguments);\n }\n\n ", "\n\n export default {\n parser,\n Parser,\n parse: yyparse,\n ", "\n };\n "]); + var data = _taggedTemplateLiteral(["\n\n ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); _templateObject159 = function _templateObject159() { return data; @@ -54,7 +74,7 @@ function _templateObject159() { } function _templateObject158() { - var data = _taggedTemplateLiteral(["\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n yyExecMain();\n }\n "]); + var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); _templateObject158 = function _templateObject158() { return data; @@ -64,7 +84,7 @@ function _templateObject158() { } function _templateObject157() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // The JISON ", " has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END -----------------------------\n //\n\n "]); _templateObject157 = function _templateObject157() { return data; @@ -74,7 +94,7 @@ function _templateObject157() { } function _templateObject156() { - var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject156 = function _templateObject156() { return data; @@ -84,7 +104,7 @@ function _templateObject156() { } function _templateObject155() { - var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // The JISON ", " has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END -----------------------------\n //\n\n "]); + var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // This is a EBNF grammar. The resulting **BNF** grammar has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END OF BNF grammar --------------\n //\n\n\n "]); _templateObject155 = function _templateObject155() { return data; @@ -94,7 +114,7 @@ function _templateObject155() { } function _templateObject154() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject154 = function _templateObject154() { return data; @@ -104,7 +124,7 @@ function _templateObject154() { } function _templateObject153() { - var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // This is a EBNF grammar. The resulting **BNF** grammar has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END OF BNF grammar --------------\n //\n\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject153 = function _templateObject153() { return data; @@ -114,7 +134,7 @@ function _templateObject153() { } function _templateObject152() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n // ============================== START lexer section =========================== \n \n %lex\n \n ", "\n\n /lex\n\n // ============================== END lexer section =============================\n\n "]); _templateObject152 = function _templateObject152() { return data; @@ -124,7 +144,7 @@ function _templateObject152() { } function _templateObject151() { - var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject151 = function _templateObject151() { return data; @@ -134,7 +154,7 @@ function _templateObject151() { } function _templateObject150() { - var data = _taggedTemplateLiteral(["\n // ============================== START lexer section =========================== \n \n %lex\n \n ", "\n\n /lex\n\n // ============================== END lexer section =============================\n\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject150 = function _templateObject150() { return data; @@ -144,7 +164,7 @@ function _templateObject150() { } function _templateObject149() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject149 = function _templateObject149() { return data; @@ -154,7 +174,7 @@ function _templateObject149() { } function _templateObject148() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject148 = function _templateObject148() { return data; @@ -164,7 +184,7 @@ function _templateObject148() { } function _templateObject147() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject147 = function _templateObject147() { return data; @@ -174,7 +194,7 @@ function _templateObject147() { } function _templateObject146() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n // options:\n "]); _templateObject146 = function _templateObject146() { return data; @@ -184,7 +204,7 @@ function _templateObject146() { } function _templateObject145() { - var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject145 = function _templateObject145() { return data; @@ -194,7 +214,7 @@ function _templateObject145() { } function _templateObject144() { - var data = _taggedTemplateLiteral(["\n // options:\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject144 = function _templateObject144() { return data; @@ -204,7 +224,7 @@ function _templateObject144() { } function _templateObject143() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); _templateObject143 = function _templateObject143() { return data; @@ -214,7 +234,7 @@ function _templateObject143() { } function _templateObject142() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n // macros:\n "]); _templateObject142 = function _templateObject142() { return data; @@ -224,7 +244,7 @@ function _templateObject142() { } function _templateObject141() { - var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); + var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); _templateObject141 = function _templateObject141() { return data; @@ -234,7 +254,7 @@ function _templateObject141() { } function _templateObject140() { - var data = _taggedTemplateLiteral(["\n // macros:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); _templateObject140 = function _templateObject140() { return data; @@ -244,7 +264,7 @@ function _templateObject140() { } function _templateObject139() { - var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); _templateObject139 = function _templateObject139() { return data; @@ -264,7 +284,7 @@ function _templateObject138() { } function _templateObject137() { - var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); _templateObject137 = function _templateObject137() { return data; @@ -274,7 +294,7 @@ function _templateObject137() { } function _templateObject136() { - var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); _templateObject136 = function _templateObject136() { return data; @@ -294,7 +314,7 @@ function _templateObject135() { } function _templateObject134() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); _templateObject134 = function _templateObject134() { return data; @@ -304,7 +324,7 @@ function _templateObject134() { } function _templateObject133() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); _templateObject133 = function _templateObject133() { return data; @@ -324,7 +344,7 @@ function _templateObject132() { } function _templateObject131() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); _templateObject131 = function _templateObject131() { return data; @@ -334,7 +354,7 @@ function _templateObject131() { } function _templateObject130() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); _templateObject130 = function _templateObject130() { return data; @@ -344,7 +364,7 @@ function _templateObject130() { } function _templateObject129() { - var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); _templateObject129 = function _templateObject129() { return data; @@ -354,7 +374,7 @@ function _templateObject129() { } function _templateObject128() { - var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject128 = function _templateObject128() { return data; @@ -364,7 +384,7 @@ function _templateObject128() { } function _templateObject127() { - var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); _templateObject127 = function _templateObject127() { return data; @@ -374,7 +394,7 @@ function _templateObject127() { } function _templateObject126() { - var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); _templateObject126 = function _templateObject126() { return data; @@ -384,7 +404,7 @@ function _templateObject126() { } function _templateObject125() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject125 = function _templateObject125() { return data; @@ -394,7 +414,7 @@ function _templateObject125() { } function _templateObject124() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); _templateObject124 = function _templateObject124() { return data; @@ -404,7 +424,7 @@ function _templateObject124() { } function _templateObject123() { - var data = _taggedTemplateLiteral(["\n %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %epsilon rule action declaration error?\n \n Erroneous area:\n ", "\n "]); _templateObject123 = function _templateObject123() { return data; @@ -414,7 +434,7 @@ function _templateObject123() { } function _templateObject122() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n epsilon production rule arrow action code block does not compile: ", "\n \n Please be aware that the reported compile error MAY be referring\n to the wrapper code which is added by JISON automatically when\n processing arrow actions: the entire action code chunk \n (including wrapper) is:\n \n ", "\n \n Erroneous area:\n ", "\n "]); _templateObject122 = function _templateObject122() { return data; @@ -424,7 +444,7 @@ function _templateObject122() { } function _templateObject121() { - var data = _taggedTemplateLiteral(["\n %epsilon rule action declaration error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n epsilon production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject121 = function _templateObject121() { return data; @@ -434,7 +454,7 @@ function _templateObject121() { } function _templateObject120() { - var data = _taggedTemplateLiteral(["\n epsilon production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n You cannot specify a precedence override for an epsilon (a.k.a. empty) rule!\n \n Erroneous area:\n ", "\n "]); _templateObject120 = function _templateObject120() { return data; @@ -444,7 +464,7 @@ function _templateObject120() { } function _templateObject119() { - var data = _taggedTemplateLiteral(["\n You cannot specify a precedence override for an epsilon (a.k.a. empty) rule!\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n production rule arrow action code block does not compile: ", "\n \n Please be aware that the reported compile error MAY be referring\n to the wrapper code which is added by JISON automatically when\n processing arrow actions: the entire action code chunk \n (including wrapper) is:\n \n ", "\n \n Erroneous area:\n ", "\n "]); _templateObject119 = function _templateObject119() { return data; @@ -454,7 +474,7 @@ function _templateObject119() { } function _templateObject118() { - var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject118 = function _templateObject118() { return data; @@ -4204,30 +4224,32 @@ var parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { - this.$[key] = yyvstack[yysp - 2][key]; - } // if there are any options, add them all, otherwise set options to NULL: - // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: + for (var key in yyvstack[yysp - 2]) { + this.$[key] = yyvstack[yysp - 2][key]; + } // if there are any options, add them all, otherwise set options to NULL: + // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { - this.$.options = yy.options; - break; - } + for (var _key in yy.options) { + this.$.options = yy.options; + break; + } - if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: + if (yy.actionInclude) { + var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: - if (asrc.trim() !== '') { - this.$.actionInclude = asrc; + if (asrc.trim() !== '') { + this.$.actionInclude = asrc; + } } - } - delete yy.options; - delete yy.actionInclude; - return this.$; + delete yy.options; + delete yy.actionInclude; + return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -4331,50 +4353,51 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - if (yyvstack[yysp]) { - switch (yyvstack[yysp].type) { - case 'macro': - this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; - break; + if (yyvstack[yysp]) { + switch (yyvstack[yysp].type) { + case 'macro': + this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; + break; - case 'names': - var condition_defs = yyvstack[yysp].names; + case 'names': + var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + for (var i = 0, len = condition_defs.length; i < len; i++) { + var name = condition_defs[i][0]; - if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { - yyparser.yyError(rmCommonWS$1(_templateObject3(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); - } + if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { + yyparser.yyError(rmCommonWS$1(_templateObject3(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + } - this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' - } // and update the `yy.startConditions` hash table as well, so we have a full set - // by the time this parser arrives at the lexer rules in the input-to-parse: + this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' + } // and update the `yy.startConditions` hash table as well, so we have a full set + // by the time this parser arrives at the lexer rules in the input-to-parse: - yy.startConditions = this.$.startConditions; - break; + yy.startConditions = this.$.startConditions; + break; - case 'unknown': - this.$.unknownDecls.push(yyvstack[yysp].body); - break; + case 'unknown': + this.$.unknownDecls.push(yyvstack[yysp].body); + break; - case 'imports': - this.$.importDecls.push(yyvstack[yysp].body); - break; + case 'imports': + this.$.importDecls.push(yyvstack[yysp].body); + break; - case 'codeSection': - this.$.codeSections.push(yyvstack[yysp].body); - break; + case 'codeSection': + this.$.codeSections.push(yyvstack[yysp].body); + break; - default: - yyparser.yyError(rmCommonWS$1(_templateObject4(), yyvstack[yysp].type, yylexer.prettyPrintRange(yylstack[yysp]))); - break; + default: + yyparser.yyError(rmCommonWS$1(_templateObject4(), yyvstack[yysp].type, yylexer.prettyPrintRange(yylstack[yysp]))); + break; + } } } - break; case 9: @@ -4434,17 +4457,19 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 0; // flag as 'inclusive' - } + for (var _i3 = 0, _len2 = lst.length; _i3 < _len2; _i3++) { + lst[_i3][1] = 0; // flag as 'inclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 13: @@ -4461,17 +4486,19 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var _lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 1; // flag as 'exclusive' - } + for (var _i4 = 0, _len3 = _lst.length; _i4 < _len3; _i4++) { + _lst[_i4][1] = 1; // flag as 'exclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: _lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 15: @@ -4488,19 +4515,21 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (srcCode) { + var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject9(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + if (rv) { + yyparser.yyError(rmCommonWS$1(_templateObject9(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + + yy.actionInclude.push(srcCode); } - yy.actionInclude.push(srcCode); + this.$ = null; } - - this.$ = null; break; case 17: @@ -4521,8 +4550,6 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; yyparser.yyError(rmCommonWS$1(_templateObject10(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); this.$ = null; break; @@ -4532,10 +4559,12 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject11(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = null; + { + var start_marker = yyvstack[yysp - 1].trim(); + var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + yyparser.yyError(rmCommonWS$1(_templateObject11(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = null; + } break; case 20: @@ -4543,13 +4572,15 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var _lst2 = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - yy.options[lst[i][0]] = lst[i][1]; - } + for (var _i5 = 0, _len4 = _lst2.length; _i5 < _len4; _i5++) { + yy.options[_lst2[_i5][0]] = _lst2[_i5][1]; + } - this.$ = null; + this.$ = null; + } break; case 21: @@ -4576,28 +4607,30 @@ var parser = { /*! Production:: definition : import_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + { + // check if there are two unvalued options: 'name path' + var _lst3 = yyvstack[yysp - 1]; + var _len5 = _lst3.length; + var body; + + if (_len5 === 2 && _lst3[0][1] === true && _lst3[1][1] === true) { + // `name path`: + body = { + name: _lst3[0][0], + path: _lst3[1][0] + }; + } else if (_len5 <= 2) { + yyparser.yyError(rmCommonWS$1(_templateObject13(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject14(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } - if (len === 2 && lst[0][1] === true && lst[1][1] === true) { - // `name path`: - body = { - name: lst[0][0], - path: lst[1][0] + this.$ = { + type: 'imports', + body: body }; - } else if (len <= 2) { - yyparser.yyError(rmCommonWS$1(_templateObject13(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject14(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); } - - this.$ = { - type: 'imports', - body: body - }; break; case 24: @@ -4613,35 +4646,39 @@ var parser = { /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) - // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + { + // check there's only 1 option which is an identifier + var _lst4 = yyvstack[yysp - 4]; + var _len6 = _lst4.length; - if (len === 1 && lst[0][1] === true) { - // `name`: - name = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1(_templateObject16(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject17(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); - } + var _name; - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + if (_len6 === 1 && _lst4[0][1] === true) { + // `name`: + _name = _lst4[0][0]; + } else if (_len6 <= 1) { + yyparser.yyError(rmCommonWS$1(_templateObject16(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject17(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); + } - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject18(), name, rv, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5]))); - } + var _srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - this.$ = { - type: 'codeSection', - body: { - qualifier: name, - include: srcCode + var _rv = checkActionBlock$1(_srcCode, yylstack[yysp - 2], yy); + + if (_rv) { + yyparser.yyError(rmCommonWS$1(_templateObject18(), _name, _rv, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5]))); } - }; + + this.$ = { + type: 'codeSection', + body: { + qualifier: _name, + include: _srcCode + } + }; + } break; case 26: @@ -4650,10 +4687,15 @@ var parser = { this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - var end_marker_msg = marker_msg.replace(/\{/g, '}'); - yyparser.yyError(rmCommonWS$1(_templateObject19(), marker_msg, end_marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 4]), yyvstack[yysp - 1].errStr)); + { + var _start_marker = yyvstack[yysp - 2].trim(); + + var _marker_msg = _start_marker ? ' or similar, such as ' + _start_marker : ''; + + var end_marker_msg = _marker_msg.replace(/\{/g, '}'); + + yyparser.yyError(rmCommonWS$1(_templateObject19(), _marker_msg, end_marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 4]), yyvstack[yysp - 1].errStr)); + } break; case 27: @@ -4787,19 +4829,21 @@ var parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var _srcCode2 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (_srcCode2) { + var _rv2 = checkActionBlock$1(_srcCode2, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject23(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + if (_rv2) { + yyparser.yyError(rmCommonWS$1(_templateObject23(), _rv2, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + + yy.actionInclude.push(_srcCode2); } - yy.actionInclude.push(srcCode); + this.$ = yyvstack[yysp - 3]; } - - this.$ = yyvstack[yysp - 3]; break; case 42: @@ -4817,10 +4861,12 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject24(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = yyvstack[yysp - 2]; + { + var _start_marker2 = yyvstack[yysp - 1].trim(); + + yyparser.yyError(rmCommonWS$1(_templateObject24(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -4828,20 +4874,24 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error - // is more probably due to indenting the rule regex, rather than an error - // in writing the action code block: + { + var _start_marker3 = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error + // is more probably due to indenting the rule regex, rather than an error + // in writing the action code block: - console.error("*** error! marker:", start_marker); - if (start_marker.indexOf('{') >= 0) { - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject25(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject26(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); - } + console.error("*** error! marker:", _start_marker3); - this.$ = yyvstack[yysp - 2]; + if (_start_marker3.indexOf('{') >= 0) { + var _marker_msg2 = _start_marker3 ? ' or similar, such as ' + _start_marker3 : ''; + + yyparser.yyError(rmCommonWS$1(_templateObject25(), _marker_msg2, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject26(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); + } + + this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -4949,14 +4999,17 @@ var parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + var _srcCode3 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject31(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); - } + var _rv3 = checkActionBlock$1(_srcCode3, yylstack[yysp - 1], yy); + + if (_rv3) { + yyparser.yyError(rmCommonWS$1(_templateObject31(), _rv3, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); + } - this.$ = [yyvstack[yysp - 3], srcCode]; + this.$ = [yyvstack[yysp - 3], _srcCode3]; + } break; case 61: @@ -4964,31 +5017,34 @@ var parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. - // - // Note/Optimization: - // there's no need for braces in the generated expression when we can - // already see the given action is an identifier string or something else - // that's a sure simple thing for a JavaScript `return` statement to carry. - // By doing this, we simplify the token return replacement code replacement - // process which will be applied to the parsed lexer before its code - // will be generated by JISON. - - if (/^[^\r\n;\/]+$/.test(srcCode)) { - srcCode = 'return ' + srcCode; - } else { - srcCode = 'return (' + srcCode + '\n)'; - } + { + var _srcCode4 = trimActionCode$1(yyvstack[yysp - 1]); // 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. + // + // Note/Optimization: + // there's no need for braces in the generated expression when we can + // already see the given action is an identifier string or something else + // that's a sure simple thing for a JavaScript `return` statement to carry. + // By doing this, we simplify the token return replacement code replacement + // process which will be applied to the parsed lexer before its code + // will be generated by JISON. - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject32(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); - } + if (/^[^\r\n;\/]+$/.test(_srcCode4)) { + _srcCode4 = 'return ' + _srcCode4; + } else { + _srcCode4 = 'return (' + _srcCode4 + '\n)'; + } + + var _rv4 = checkActionBlock$1(_srcCode4, yylstack[yysp - 1], yy); - this.$ = [yyvstack[yysp - 3], srcCode]; + if (_rv4) { + yyparser.yyError(rmCommonWS$1(_templateObject32(), _rv4, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); + } + + this.$ = [yyvstack[yysp - 3], _srcCode4]; + } break; case 62: @@ -5108,20 +5164,21 @@ var parser = { /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; // Validate the given condition state: when it isn't known, print an error message - // accordingly: - - if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { - yyparser.yyError(rmCommonWS$1(_templateObject41(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp]))); - } + { + // rewrite + accept star '*' as name + check if we allow empty list? + this.$ = yyvstack[yysp - 2].map(function (el) { + var name = el[0]; // Validate the given condition state: when it isn't known, print an error message + // accordingly: - return name; - }); // '<' '*' '>' - // { $$ = ['*']; } + if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { + yyparser.yyError(rmCommonWS$1(_templateObject41(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp]))); + } + return name; + }); // '<' '*' '>' + // { $$ = ['*']; } + } break; case 74: @@ -5129,78 +5186,82 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { - return el[0]; - }); - yyparser.yyError(rmCommonWS$1(_templateObject42(), lst.join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + { + // rewrite + accept star '*' as name + check if we allow empty list? + var _lst5 = yyvstack[yysp - 1].map(function (el) { + return el[0]; + }); + + yyparser.yyError(rmCommonWS$1(_templateObject42(), _lst5.join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + } break; case 75: /*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // Detect if the regex ends with a pure (Unicode) word; - // we *do* consider escaped characters which are 'alphanumeric' - // to be equivalent to their non-escaped version, hence these are - // all valid 'words' for the 'easy keyword rules' option: - // - // - hello_kitty - // - γεια_σου_γατούλα - // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 - // - // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 - // - // As we only check the *tail*, we also accept these as - // 'easy keywords': - // - // - %options - // - %foo-bar - // - +++a:b:c1 - // - // Note the dash in that last example: there the code will consider - // `bar` to be the keyword, which is fine with us as we're only - // interested in the trailing boundary and patching that one for - // the `easy_keyword_rules` option. - - this.$ = yyvstack[yysp]; - - if (yy.options.easy_keyword_rules) { - // We need to 'protect' `eval` here as keywords are allowed - // to contain double-quotes and other leading cruft. - // `eval` *does* gobble some escapes (such as `\b`) but - // we protect against that through a simple replace regex: - // we're not interested in the special escapes' exact value - // anyway. - // It will also catch escaped escapes (`\\`), which are not - // word characters either, so no need to worry about - // `eval(str)` 'correctly' converting convoluted constructs - // like '\\\\\\\\\\b' in here. - this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); - - try { - // Convert Unicode escapes and other escapes to their literal characters - // BEFORE we go and check whether this item is subject to the - // `easy_keyword_rules` option. - this.$ = JSON.parse('"' + this.$ + '"'); - } catch (ex) { - yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: - - this.$ = '.'; - } // a 'keyword' starts with an alphanumeric character, - // followed by zero or more alphanumerics or digits: + { + // Detect if the regex ends with a pure (Unicode) word; + // we *do* consider escaped characters which are 'alphanumeric' + // to be equivalent to their non-escaped version, hence these are + // all valid 'words' for the 'easy keyword rules' option: + // + // - hello_kitty + // - γεια_σου_γατούλα + // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 + // + // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 + // + // As we only check the *tail*, we also accept these as + // 'easy keywords': + // + // - %options + // - %foo-bar + // - +++a:b:c1 + // + // Note the dash in that last example: there the code will consider + // `bar` to be the keyword, which is fine with us as we're only + // interested in the trailing boundary and patching that one for + // the `easy_keyword_rules` option. + this.$ = yyvstack[yysp]; - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); - - if (XRegExp__default['default'].match(this.$, re)) { - this.$ = yyvstack[yysp] + "\\b"; - } else { - this.$ = yyvstack[yysp]; + if (yy.options.easy_keyword_rules) { + // We need to 'protect' `eval` here as keywords are allowed + // to contain double-quotes and other leading cruft. + // `eval` *does* gobble some escapes (such as `\b`) but + // we protect against that through a simple replace regex: + // we're not interested in the special escapes' exact value + // anyway. + // It will also catch escaped escapes (`\\`), which are not + // word characters either, so no need to worry about + // `eval(str)` 'correctly' converting convoluted constructs + // like '\\\\\\\\\\b' in here. + this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); + + try { + // Convert Unicode escapes and other escapes to their literal characters + // BEFORE we go and check whether this item is subject to the + // `easy_keyword_rules` option. + this.$ = JSON.parse('"' + this.$ + '"'); + } catch (ex) { + yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: + + this.$ = '.'; + } // a 'keyword' starts with an alphanumeric character, + // followed by zero or more alphanumerics or digits: + + + var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + + if (XRegExp__default['default'].match(this.$, re)) { + this.$ = yyvstack[yysp] + "\\b"; + } else { + this.$ = yyvstack[yysp]; + } } } - break; case 76: @@ -5418,10 +5479,14 @@ var parser = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; - this.$ = encodeRegexLiteralStr(s, edge); + { + var src = yyvstack[yysp]; + + var _s = src.substring(1, src.length - 1); + + var edge = src[0]; + this.$ = encodeRegexLiteralStr(_s, edge); + } break; case 112: @@ -5429,30 +5494,34 @@ var parser = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; - this.$ = encodeRegexLiteralStr(s); + { + var _s2 = yyvstack[yysp]; + this.$ = encodeRegexLiteralStr(_s2); + } break; case 113: /*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal behaviour under the given circumstances, i.e. parser context: - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { - yyparser.yyError(rmCommonWS$1(_templateObject45(), yy.__options_category_description__, yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4]))); - } + { + // validate that this is legal behaviour under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { + yyparser.yyError(rmCommonWS$1(_templateObject45(), yy.__options_category_description__, yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4]))); + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { - return opt[0]; - }); - optlist.push(yyvstack[yysp][0]); - yyparser.yyError(rmCommonWS$1(_templateObject46(), yy.__options_category_description__, yyvstack[yysp - 4], optlist.join(' '), yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4]))); - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { + var optlist = yyvstack[yysp - 2].map(function (opt) { + return opt[0]; + }); + optlist.push(yyvstack[yysp][0]); + yyparser.yyError(rmCommonWS$1(_templateObject46(), yy.__options_category_description__, yyvstack[yysp - 4], optlist.join(' '), yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4]))); + } - this.$ = yyvstack[yysp - 2]; - this.$.push(yyvstack[yysp]); + this.$ = yyvstack[yysp - 2]; + this.$.push(yyvstack[yysp]); + } break; case 114: @@ -5514,60 +5583,64 @@ var parser = { this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + var with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1(_templateObject50(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$1(_templateObject50(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]), yyvstack[yysp].errStr)); + } break; case 120: /*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - - if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { - this.$ = mkIdentifier$2(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; - // if not, report an error as we don't want confusion due to - // typos and/or garbage input here producing something that - // is usable from a machine perspective. - if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { + this.$ = mkIdentifier$2(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; + // if not, report an error as we don't want confusion due to + // typos and/or garbage input here producing something that + // is usable from a machine perspective. + + if (!isLegalIdentifierInput$1(yyvstack[yysp])) { + var _with_value_msg = ' (with optional value assignment)'; + + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + _with_value_msg = ''; + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; + yyparser.yyError(rmCommonWS$1(_templateObject51(), _with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } - - yyparser.yyError(rmCommonWS$1(_templateObject51(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } else { + this.$ = yyvstack[yysp]; } - } else { - this.$ = yyvstack[yysp]; } - break; case 121: /*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { - this.$ = yyvstack[yysp]; - } else { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { + this.$ = yyvstack[yysp]; + } else { + var _with_value_msg2 = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + _with_value_msg2 = ''; + } - yyparser.yyError(rmCommonWS$1(_templateObject52(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$1(_templateObject52(), _with_value_msg2, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } } - break; case 122: @@ -5599,17 +5672,19 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + var _srcCode5 = trimActionCode$1(yyvstack[yysp]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + if (_srcCode5) { + var _rv5 = checkActionBlock$1(_srcCode5, yylstack[yysp], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject53(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + if (_rv5) { + yyparser.yyError(rmCommonWS$1(_templateObject53(), _rv5, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } } - } - this.$ = srcCode; + this.$ = _srcCode5; + } break; case 126: @@ -5636,20 +5711,22 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var _srcCode6 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (_srcCode6) { + var _rv6 = checkActionBlock$1(_srcCode6, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject56(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); - } - } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) - // we append those protective double newlines right now, as the calling site - // won't do it for us: + if (_rv6) { + yyparser.yyError(rmCommonWS$1(_templateObject56(), _rv6, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) + // we append those protective double newlines right now, as the calling site + // won't do it for us: - this.$ = '\n\n' + srcCode + '\n\n'; + this.$ = '\n\n' + _srcCode6 + '\n\n'; + } break; case 131: @@ -5657,10 +5734,12 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject57(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = ''; + { + var _start_marker4 = yyvstack[yysp - 1].trim(); + + yyparser.yyError(rmCommonWS$1(_templateObject57(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = ''; + } break; case 133: @@ -5677,36 +5756,40 @@ var parser = { /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) - // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + { + // check if there is only 1 unvalued options: 'path' + var _lst6 = yyvstack[yysp - 1]; + var _len7 = _lst6.length; + + var _path; - if (len === 1 && lst[0][1] === true) { - // `path`: - path = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1(_templateObject58(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject59(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); - } // **Aside**: And no, we don't support nested '%include'! + if (_len7 === 1 && _lst6[0][1] === true) { + // `path`: + _path = _lst6[0][0]; + } else if (_len7 <= 1) { + yyparser.yyError(rmCommonWS$1(_templateObject58(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject59(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); + } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { - encoding: 'utf-8' - }); - var srcCode = trimActionCode$1(fileContent); + var fileContent = fs__default['default'].readFileSync(_path, { + encoding: 'utf-8' + }); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + var _srcCode7 = trimActionCode$1(fileContent); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject60(), path, rv, yylexer.prettyPrintRange(this._$))); + if (_srcCode7) { + var _rv7 = checkActionBlock$1(_srcCode7, this._$, yy); + + if (_rv7) { + yyparser.yyError(rmCommonWS$1(_templateObject60(), _path, _rv7, yylexer.prettyPrintRange(this._$))); + } } - } - this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + this.$ = '\n// Included by Jison: ' + _path + ':\n\n' + _srcCode7 + '\n\n// End Of Include by Jison: ' + _path + '\n\n'; + } break; case 135: @@ -5896,12 +5979,14 @@ var parser = { if (recoveringErrorInfo) { var esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); - v.yyError = true; - v.errorRuleDepth = error_rule_depth; - v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; - recoveringErrorInfo.value_stack[esp] = v; + var _v = this.shallowCopyErrorInfo(hash); + + _v.yyError = true; + _v.errorRuleDepth = error_rule_depth; + _v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; + + recoveringErrorInfo.value_stack[esp] = _v; recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc); recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1]; ++esp; @@ -6026,8 +6111,8 @@ var parser = { this.__error_infos.length = 0; - for (var _i3 = this.__error_recovery_infos.length - 1; _i3 >= 0; _i3--) { - var _el = this.__error_recovery_infos[_i3]; + for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { + var _el = this.__error_recovery_infos[_i6]; if (_el && typeof _el.destroy === 'function') { _el.destroy(); @@ -6079,8 +6164,8 @@ var parser = { if (!l2) { if (last_index != null) { - for (var _i4 = i2; _i4 >= i1; _i4--) { - l2 = lstack[_i4]; + for (var _i7 = i2; _i7 >= i1; _i7--) { + l2 = lstack[_i7]; if (l2) { break; @@ -6093,8 +6178,8 @@ var parser = { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var _i5 = (i1 || sp) - 1; _i5 >= 0; _i5--) { - l1 = lstack[_i5]; + for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { + l1 = lstack[_i8]; if (l1) { break; @@ -9006,19 +9091,21 @@ var lexer = function () { /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; - var l = scanRegExp(yy_.yytext); + { + yy.include_command_allowed = false; + var l = scanRegExp(yy_.yytext); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); - yy_.yytext = yy_.yytext[0]; - } + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - return 35; + return 35; + } case 10: /*! Conditions:: action */ @@ -9106,65 +9193,67 @@ var lexer = function () { /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - yy.include_command_allowed = false; - this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - - var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + + var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + + var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + var atSOL = !precedingStr + /* @ Start Of File */ + || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + + var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - var prevEnd = 0; - var endMarkerIndex; + var remaining = this.lookAhead(); + var prevEnd = 0; + var endMarkerIndex; - for (;;) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + for (;;) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS(_templateObject65(), endMarker) + this.prettyPrintRange(yy_.yylloc)); - return 24; - } + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS(_templateObject65(), endMarker) + this.prettyPrintRange(yy_.yylloc)); + return 24; + } - break; - } // Allow the start marker to be re-matched by the generated lexer rule regex: + break; + } // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; - } + if (atSOL) { + return 22; + } - return 25; + return 25; + } case 20: /*! Conditions:: rules macro INITIAL */ @@ -9197,41 +9286,43 @@ var lexer = function () { /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); - - this.pushState('action'); // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - - var la = this.lookAhead(); - - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser - } + { + yy.depth = 0; + yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); + + this.pushState('action'); // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + + var la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - return 25; + return 25; + } case 24: /*! Conditions:: rules */ @@ -9388,32 +9479,39 @@ var lexer = function () { /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); - yy_.yytext = v; - } + { + var m = this.matches; + yy_.yytext = NaN; - return 43; + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + var _v2 = parseInt(m[1], 8); + + yy_.yytext = _v2; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + var _v3 = m[2].charCodeAt(0) - 64; + + yy_.yytext = _v3; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + var _v4 = parseInt(m[3], 16); + + yy_.yytext = _v4; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + var _v5 = parseInt(m[4], 16); + + yy_.yytext = _v5; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + var _v6 = parseInt(m[5], 16); + + yy_.yytext = _v6; + } + + return 43; + } case 70: /*! Conditions:: rules macro INITIAL */ @@ -9461,26 +9559,30 @@ var lexer = function () { /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; - yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; - this.pushState('action'); // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': + { + yy.depth = 0; + yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. - this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + var _precedingStr = this.matched[this.matched.length - this.match.length - 1]; - if (atSOL) { - return 22; - } + var _atSOL = !_precedingStr + /* @ Start Of File */ + || _precedingStr === '\n'; - return 25; + this.pushState('action'); // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + + this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + + if (_atSOL) { + return 22; + } + + return 25; + } case 81: /*! Conditions:: INITIAL rules code */ @@ -9571,35 +9673,45 @@ var lexer = function () { /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject73(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS(_templateObject73(), rules) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject74(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var _rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject74(), _rules) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject75(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var _rules2 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject75(), _rules2) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ + { + /* b0rk on bad characters */ + var _rules3 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject76(), rules, dquote(this.topState()), rules) + this.prettyPrintRange(yy_.yylloc)); - return 2; + yy_.yyerror(rmCommonWS(_templateObject76(), _rules3, dquote(this.topState()), _rules3) + this.prettyPrintRange(yy_.yylloc)); + return 2; + } case 104: /*! Conditions:: options */ @@ -10243,28 +10355,28 @@ function encodeRegexLiteralStr(s, edge) { var rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + var _c = s[i]; - switch (c) { + switch (_c) { case '\\': i++; if (i < l) { - c = s[i]; + _c = s[i]; - if (c === edge) { - rv += c; + if (_c === edge) { + rv += _c; continue; } - var pos = '\'"`'.indexOf(c); + var _pos = '\'"`'.indexOf(_c); - if (pos >= 0) { - rv += '\\\\' + c; + if (_pos >= 0) { + rv += '\\\\' + _c; continue; } - if (c === '\\') { + if (_c === '\\') { rv += '\\\\'; continue; } @@ -10299,40 +10411,45 @@ function encodeRegexLiteralStr(s, edge) { if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); - rv += encodeCharCode(v); + var _v7 = parseInt(m[4], 8); + + rv += encodeCharCode(_v7); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; - rv += encodeCharCode(v); + var _v8 = m[5].charCodeAt(0) - 64; + + rv += encodeCharCode(_v8); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); - rv += encodeCharCode(v); + var _v9 = parseInt(m[6], 16); + + rv += encodeCharCode(_v9); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); - rv += encodeCharCode(v); + var _v10 = parseInt(m[7], 16); + + rv += encodeCharCode(_v10); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); - rv += encodeUnicodeCodepoint(v); + var _v11 = parseInt(m[8], 16); + + rv += encodeUnicodeCodepoint(_v11); i += m[8].length; continue; } @@ -10346,21 +10463,21 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + var pos = ".*+?^${}()|[]/\\".indexOf(_c); if (pos >= 0) { - rv += '\\' + c; + rv += '\\' + _c; continue; } - var cc = charCvtTable[c]; + var cc = charCvtTable[_c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = _c.charCodeAt(0); if (cc < 32) { var rvp = codeCvtTable[v]; @@ -10371,7 +10488,7 @@ function encodeRegexLiteralStr(s, edge) { rv += "\\u" + ('0000' + cc.toString(16)).substr(-4); } } else { - rv += c; + rv += _c; } continue; @@ -11803,7 +11920,14 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) simple_rule_count++; caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { - regular_rule_count++; + regular_rule_count++; // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } + routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } @@ -12724,7 +12848,7 @@ function stripUnusedLexerCode(src, opt) { var minl = Math.max(0, line - 10); var b = a.slice(minl, line + 10); - var _c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); + var _c2 = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); var offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2(_templateObject82(), ex, offendingChunk)); @@ -17014,9 +17138,6 @@ var parser$3 = { case 101: /*! Production:: suffix : %epsilon */ - case 117: - /*! Production:: action : %epsilon */ - case 118: /*! Production:: action_body : %epsilon */ @@ -17033,13 +17154,15 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (rv) { + yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = yyvstack[yysp]; + this.$ = yyvstack[yysp]; + } break; case 6: @@ -17061,16 +17184,19 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + this.$ = yyvstack[yysp - 1]; - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject94(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + var _rv8 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - yy.addDeclaration(this.$, { - actionInclude: yyvstack[yysp] - }); + if (_rv8) { + yyparser.yyError(rmCommonWS$3(_templateObject94(), _rv8, yylexer.prettyPrintRange(yylstack[yysp]))); + } + + yy.addDeclaration(this.$, { + actionInclude: yyvstack[yysp] + }); + } break; case 9: @@ -17140,15 +17266,17 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var _rv9 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (_rv9) { + yyparser.yyError(rmCommonWS$3(_templateObject96(), _rv9, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = { - include: yyvstack[yysp] - }; + this.$ = { + include: yyvstack[yysp] + }; + } break; case 17: @@ -17156,15 +17284,17 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var _rv10 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject97(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (_rv10) { + yyparser.yyError(rmCommonWS$3(_templateObject97(), _rv10, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = { - include: yyvstack[yysp] - }; + this.$ = { + include: yyvstack[yysp] + }; + } break; case 18: @@ -17264,18 +17394,20 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); - } + { + var _rv11 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - this.$ = { - initCode: { - qualifier: yyvstack[yysp - 1], - include: yyvstack[yysp] + if (_rv11) { + yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, _rv11, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } - }; + + this.$ = { + initCode: { + qualifier: yyvstack[yysp - 1], + include: yyvstack[yysp] + } + }; + } break; case 28: @@ -17377,9 +17509,6 @@ var parser$3 = { case 114: /*! Production:: action_ne : include_macro_code */ - case 115: - /*! Production:: action : action_ne */ - case 119: /*! Production:: action_body : action_comments_body */ @@ -17589,23 +17718,25 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; + { + var _rv12 = []; + var lst = yyvstack[yysp]; + + for (var i = 0, len = lst.length; i < len; i++) { + var id = lst[i]; + var m = { + id: id + }; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = { - id: id - }; + if (yyvstack[yysp - 1]) { + m.type = yyvstack[yysp - 1]; + } - if (yyvstack[yysp - 1]) { - m.type = yyvstack[yysp - 1]; + _rv12.push(m); } - rv.push(m); + this.$ = _rv12; } - - this.$ = rv; break; case 62: @@ -17613,13 +17744,15 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + var _m = yyvstack[yysp]; - if (yyvstack[yysp - 1]) { - m.type = yyvstack[yysp - 1]; - } + if (yyvstack[yysp - 1]) { + _m.type = yyvstack[yysp - 1]; + } - this.$ = [m]; + this.$ = [_m]; + } break; case 63: @@ -17796,32 +17929,38 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - this.$ = [yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '']; + { + this.$ = [yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '']; - if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + if (yyvstack[yysp]) { + var _rv13 = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject118(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + if (_rv13) { + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3(_templateObject118(), _rv13, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } else { + var indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + yyparser.yyError(rmCommonWS$3(_templateObject119(), _rv13, indentedSrc, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } + } + + this.$.push(yyvstack[yysp].action); } - this.$.push(yyvstack[yysp]); - } + if (yyvstack[yysp - 1]) { + if (yyvstack[yysp - 2].length === 0) { + yyparser.yyError(rmCommonWS$3(_templateObject120(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] + /* @handle is very probably NULL! We need this one for some decent location info! */ + ))); + } - if (yyvstack[yysp - 1]) { - if (yyvstack[yysp - 2].length === 0) { - yyparser.yyError(rmCommonWS$3(_templateObject119(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] - /* @handle is very probably NULL! We need this one for some decent location info! */ - ))); + this.$.push(yyvstack[yysp - 1]); } - this.$.push(yyvstack[yysp - 1]); - } - - if (this.$.length === 1) { - this.$ = this.$[0]; + if (this.$.length === 1) { + this.$ = this.$[0]; + } } - break; case 88: @@ -17829,22 +17968,29 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = ['']; + { + this.$ = ['']; - if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + if (yyvstack[yysp]) { + var _rv14 = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject120(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); - } + if (_rv14) { + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3(_templateObject121(), _rv14, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } else { + var _indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); - this.$.push(yyvstack[yysp]); - } + yyparser.yyError(rmCommonWS$3(_templateObject122(), _rv14, _indentedSrc, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } + } - if (this.$.length === 1) { - this.$ = this.$[0]; - } + this.$.push(yyvstack[yysp].action); + } + if (this.$.length === 1) { + this.$ = this.$[0]; + } + } break; case 89: @@ -17854,7 +18000,7 @@ var parser$3 = { this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 90: @@ -17947,7 +18093,7 @@ var parser$3 = { this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 105: @@ -17967,11 +18113,14 @@ var parser$3 = { this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 107: - /*! Production:: prec : %epsilon */ + /*! Production:: prec : %epsilon */ + + case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) @@ -17984,7 +18133,18 @@ var parser$3 = { this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject126(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + break; + + case 115: + /*! Production:: action : action_ne */ + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; break; case 116: @@ -17992,7 +18152,13 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + var src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: "\n this.$ = (\n ".concat(src, "\n );\n "), + isArrowAction: true + }; + } break; case 120: @@ -18017,7 +18183,7 @@ var parser$3 = { this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject127(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 126: @@ -18033,17 +18199,20 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { - encoding: 'utf-8' - }); - var rv = checkActionBlock$2(fileContent); + { + var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { + encoding: 'utf-8' + }); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject126(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); - } // And no, we don't support nested '%include': + var _rv15 = checkActionBlock$2(fileContent); + + if (_rv15) { + yyparser.yyError(rmCommonWS$3(_templateObject128(), $PATH, _rv15, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } // And no, we don't support nested '%include': - this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -18052,7 +18221,7 @@ var parser$3 = { this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); + yyparser.yyError(rmCommonWS$3(_templateObject129()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); break; case 131: @@ -18062,7 +18231,7 @@ var parser$3 = { this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject128()) + yylexer.prettyPrintRange(yylstack[yysp])); + yyparser.yyError(rmCommonWS$3(_templateObject130()) + yylexer.prettyPrintRange(yylstack[yysp])); break; } }, @@ -18243,12 +18412,14 @@ var parser$3 = { if (recoveringErrorInfo) { var esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); - v.yyError = true; - v.errorRuleDepth = error_rule_depth; - v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; - recoveringErrorInfo.value_stack[esp] = v; + var _v12 = this.shallowCopyErrorInfo(hash); + + _v12.yyError = true; + _v12.errorRuleDepth = error_rule_depth; + _v12.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; + + recoveringErrorInfo.value_stack[esp] = _v12; recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc); recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1]; ++esp; @@ -18373,8 +18544,8 @@ var parser$3 = { this.__error_infos.length = 0; - for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { - var _el2 = this.__error_recovery_infos[_i6]; + for (var _i9 = this.__error_recovery_infos.length - 1; _i9 >= 0; _i9--) { + var _el2 = this.__error_recovery_infos[_i9]; if (_el2 && typeof _el2.destroy === 'function') { _el2.destroy(); @@ -18426,8 +18597,8 @@ var parser$3 = { if (!l2) { if (last_index != null) { - for (var _i7 = i2; _i7 >= i1; _i7--) { - l2 = lstack[_i7]; + for (var _i10 = i2; _i10 >= i1; _i10--) { + l2 = lstack[_i10]; if (l2) { break; @@ -18440,8 +18611,8 @@ var parser$3 = { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { - l1 = lstack[_i8]; + for (var _i11 = (i1 || sp) - 1; _i11 >= 0; _i11--) { + l1 = lstack[_i11]; if (l1) { break; @@ -21484,7 +21655,7 @@ var lexer$2 = function () { /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */ - this.warn(rmCommonWS(_templateObject129(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + this.warn(rmCommonWS(_templateObject131(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); yy_.yytext = [// {NAME} this.matches[1], // optional value/parameters this.matches[2].trim()]; @@ -21605,67 +21776,75 @@ var lexer$2 = function () { /*! Conditions:: action */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 82: /*! Conditions:: action */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 83: /*! Conditions:: action */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 84: /*! Conditions:: option_values */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 85: /*! Conditions:: option_values */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject136()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 86: /*! Conditions:: option_values */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject137()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var _rules4 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject139(), _rules4) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var _rules5 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject140(), _rules5) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ @@ -21673,7 +21852,7 @@ var lexer$2 = function () { /*! Rule:: . */ /* b0rk on bad characters */ - yy_.yyerror(rmCommonWS(_templateObject139(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject141(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); return 2; default: @@ -22131,7 +22310,8 @@ parser$3.lexer = lexer$2; var ebnf = false; var rmCommonWS$3 = helpers.rmCommonWS; var dquote$2 = helpers.dquote; -var checkActionBlock$2 = helpers.checkActionBlock; // transform ebnf to bnf if necessary +var checkActionBlock$2 = helpers.checkActionBlock; +var trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary function extend(json, grammar) { if (ebnf) { @@ -22523,7 +22703,7 @@ function grammarPrinter(raw, options) { delete raw.lex.macros; if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject140())); + lex_pre.push(rmCommonWS$4(_templateObject142())); var keylen = 0; for (var key in src) { @@ -22534,11 +22714,11 @@ function grammarPrinter(raw, options) { keylen = (keylen / 4 | 0) * 4 + 4; console.log('macros keylen B:', keylen); - for (var _key in src) { - lex_pre.push(padRight(_key, keylen) + src[_key]); + for (var _key2 in src) { + lex_pre.push(padRight(_key2, keylen) + src[_key2]); } - lex_pre.push(rmCommonWS$4(_templateObject141())); + lex_pre.push(rmCommonWS$4(_templateObject143())); } } { @@ -22546,16 +22726,16 @@ function grammarPrinter(raw, options) { delete raw.lex.unknownDecls; if (_src && !isEmptyObj(_src)) { - lex_pre.push(rmCommonWS$4(_templateObject142())); + lex_pre.push(rmCommonWS$4(_templateObject144())); for (var i = 0, len = _src.length; i < len; i++) { var entry = _src[i]; - var _key2 = entry.name; + var _key3 = entry.name; var value = entry.value; - lex_pre.push('%' + _key2 + ' ' + value); + lex_pre.push('%' + _key3 + ' ' + value); } - lex_pre.push(rmCommonWS$4(_templateObject143())); + lex_pre.push(rmCommonWS$4(_templateObject145())); } } { @@ -22563,15 +22743,15 @@ function grammarPrinter(raw, options) { delete raw.lex.options; if (_src2 && !isEmptyObj(_src2)) { - lex_pre.push(rmCommonWS$4(_templateObject144())); + lex_pre.push(rmCommonWS$4(_templateObject146())); - for (var _key3 in _src2) { - var _value = _src2[_key3]; + for (var _key4 in _src2) { + var _value = _src2[_key4]; if (_value) { - lex_pre.push('%options ' + _key3 + '=' + _value); + lex_pre.push('%options ' + _key4 + '=' + _value); } else { - lex_pre.push('%options ' + _key3); + lex_pre.push('%options ' + _key4); } } } @@ -22581,9 +22761,9 @@ function grammarPrinter(raw, options) { delete raw.lex.startConditions; if (_src3 && !isEmptyObj(_src3)) { - for (var _key4 in _src3) { - var _value2 = _src3[_key4]; - lex_pre.push((_value2 ? '%x ' : '%s ') + _key4); + for (var _key5 in _src3) { + var _value2 = _src3[_key5]; + lex_pre.push((_value2 ? '%x ' : '%s ') + _key5); } } } @@ -22600,9 +22780,9 @@ function grammarPrinter(raw, options) { delete raw.lex.rules; if (_src5) { - for (var _i9 = 0, _len2 = _src5.length; _i9 < _len2; _i9++) { - var _entry = _src5[_i9]; - var _key5 = _entry[0]; + for (var _i12 = 0, _len8 = _src5.length; _i12 < _len8; _i12++) { + var _entry = _src5[_i12]; + var _key6 = _entry[0]; var action = indentAction(_entry[1], 4); var actionHasLF = /[\r\n]/.test(action); console.log('indented action:', { @@ -22611,16 +22791,16 @@ function grammarPrinter(raw, options) { actionHasLF: actionHasLF }); - if (_key5.length <= 12) { + if (_key6.length <= 12) { if (!actionHasLF) { - lex_rules.push(padRight(_key5, 16) + indentAction(action, 16)); + lex_rules.push(padRight(_key6, 16) + indentAction(action, 16)); } else { - lex_rules.push(padRight(_key5, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(padRight(_key6, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } else if (!actionHasLF) { - lex_rules.push(_key5, makeIndent(16) + indentAction(action, 16)); + lex_rules.push(_key6, makeIndent(16) + indentAction(action, 16)); } else { - lex_rules.push(_key5, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(_key6, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } @@ -22639,15 +22819,15 @@ function grammarPrinter(raw, options) { if (!isEmptyObj(raw.lex)) { // dump the remainder as a comment: var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4(_templateObject145(), rem.replace(/\*\//g, '*\\/')); + out += rmCommonWS$4(_templateObject147(), rem.replace(/\*\//g, '*\\/')); } delete raw.lex; out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject146()) + lex_rules.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject148()) + lex_rules.join('\n') + '\n\n'; if (lex_post.length > 0) { - out += rmCommonWS$4(_templateObject147()) + lex_post.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject149()) + lex_post.join('\n') + '\n\n'; } lex_out_str = out; @@ -22719,69 +22899,69 @@ function grammarPrinter(raw, options) { var grammarfmt = function grammarfmt(src) { var dst = []; - for (var _key6 in src) { - var prodset = src[_key6]; + for (var _key7 in src) { + var prodset = src[_key7]; var rule = void 0; console.log('format one rule:', { - key: _key6, + key: _key7, prodset: prodset }); if (typeof prodset === 'string') { - rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; - delete src[_key6]; + rule = fmtprod(_key7 + ' : ', [prodset]) + ';'; + delete src[_key7]; } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; - delete src[_key6]; + rule = fmtprod(_key7 + ' : ', [prodset]) + ';'; + delete src[_key7]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(_key6 + ' : ', prodset[0]); + rule = fmtprod(_key7 + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { - delete src[_key6]; + delete src[_key7]; } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(_key6 + '\n : ', [prodset[0]]); + rule = fmtprod(_key7 + '\n : ', [prodset[0]]); delete prodset[0]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(_key6 + '\n : ', prodset[0]); + rule = fmtprod(_key7 + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var _i10 = 1, _len3 = prodset.length; _i10 < _len3; _i10++) { - if (typeof prodset[_i10] === 'string') { - rule += fmtprod('\n | ', [prodset[_i10]]); - delete prodset[_i10]; - } else if (prodset[_i10] instanceof Array) { - rule += fmtprod('\n | ', prodset[_i10]); + for (var _i13 = 1, _len9 = prodset.length; _i13 < _len9; _i13++) { + if (typeof prodset[_i13] === 'string') { + rule += fmtprod('\n | ', [prodset[_i13]]); + delete prodset[_i13]; + } else if (prodset[_i13] instanceof Array) { + rule += fmtprod('\n | ', prodset[_i13]); - if (prodset[_i10].length === 0) { - delete prodset[_i10]; + if (prodset[_i13].length === 0) { + delete prodset[_i13]; } } else { - rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i10]; + rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i13]; } } rule += '\n ;'; if (isEmptyArr(prodset)) { - delete src[_key6]; + delete src[_key7]; } } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -22817,23 +22997,23 @@ function grammarPrinter(raw, options) { delete raw.unknownDecls; if (_src9 && !isEmptyObj(_src9)) { - lex_pre.push(rmCommonWS$4(_templateObject148())); + lex_pre.push(rmCommonWS$4(_templateObject150())); - for (var _i11 = 0, _len4 = _src9.length; _i11 < _len4; _i11++) { - var _entry2 = _src9[_i11]; - var _key7 = _entry2.name; + for (var _i14 = 0, _len10 = _src9.length; _i14 < _len10; _i14++) { + var _entry2 = _src9[_i14]; + var _key8 = _entry2.name; var _value3 = _entry2.value; - lex_pre.push('%' + _key7 + ' ' + _value3); + lex_pre.push('%' + _key8 + ' ' + _value3); } - lex_pre.push(rmCommonWS$4(_templateObject149())); + lex_pre.push(rmCommonWS$4(_templateObject151())); } } //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { - grammar_pre.push(rmCommonWS$4(_templateObject150(), lex_out_str)); + grammar_pre.push(rmCommonWS$4(_templateObject152(), lex_out_str)); } { @@ -22843,38 +23023,38 @@ function grammarPrinter(raw, options) { if (_src10 && !isEmptyObj(_src10)) { var a = []; - for (var _key8 in _src10) { - var _value4 = _src10[_key8]; + for (var _key9 in _src10) { + var _value4 = _src10[_key9]; - switch (_key8) { + switch (_key9) { default: if (_value4 !== true) { - a.push('options', '%options ' + _key8 + '=' + _value4); + a.push('options', '%options ' + _key9 + '=' + _value4); } else { - a.push('options', '%options ' + _key8); + a.push('options', '%options ' + _key9); } break; case 'ebnf': if (_value4) { - a.push(_key8, '%ebnf'); + a.push(_key9, '%ebnf'); } break; case 'type': if (_value4) { - a.push(_key8, '%parser-type ' + _value4); + a.push(_key9, '%parser-type ' + _value4); } break; case 'debug': if (typeof _value4 !== 'boolean') { - a.push(_key8, '%debug ' + _value4); + a.push(_key9, '%debug ' + _value4); } else if (_value4) { - a.push(_key8, '%debug'); + a.push(_key9, '%debug'); } break; @@ -22883,9 +23063,9 @@ function grammarPrinter(raw, options) { var type = null; - for (var _i12 = 0, _len5 = a.length; _i12 < _len5; _i12 += 2) { - var t = a[_i12]; - var line = a[_i12 + 1]; + for (var _i15 = 0, _len11 = a.length; _i15 < _len11; _i15 += 2) { + var t = a[_i15]; + var line = a[_i15 + 1]; if (t !== type) { type = t; @@ -22904,14 +23084,14 @@ function grammarPrinter(raw, options) { if (_src11) { var clean = true; - for (var _i13 = 0, _len6 = _src11.length; _i13 < _len6; _i13++) { - var _entry3 = _src11[_i13]; + for (var _i16 = 0, _len12 = _src11.length; _i16 < _len12; _i16++) { + var _entry3 = _src11[_i16]; grammar_pre.push('%import ' + _entry3.name + ' ' + _entry3.path); delete _entry3.name; delete _entry3.path; if (isEmptyObj(_entry3)) { - delete _src11[_i13]; + delete _src11[_i16]; } else { clean = false; } @@ -22928,14 +23108,14 @@ function grammarPrinter(raw, options) { if (_src12) { var _clean = true; - for (var _i14 = 0, _len7 = _src12.length; _i14 < _len7; _i14++) { - var _entry4 = _src12[_i14]; + for (var _i17 = 0, _len13 = _src12.length; _i17 < _len13; _i17++) { + var _entry4 = _src12[_i17]; grammar_pre.push('%code ' + _entry4.qualifier + ' ' + _entry4.include); delete _entry4.qualifier; delete _entry4.include; if (isEmptyObj(_entry4)) { - delete _src12[_i14]; + delete _src12[_i17]; } else { _clean = false; } @@ -22952,8 +23132,8 @@ function grammarPrinter(raw, options) { if (_src13) { var _clean2 = true; - for (var _i15 = 0, _len8 = _src13.length; _i15 < _len8; _i15++) { - var _entry5 = _src13[_i15]; + for (var _i18 = 0, _len14 = _src13.length; _i18 < _len14; _i18++) { + var _entry5 = _src13[_i18]; var tokens = _entry5[1]; var _line = '%' + _entry5[0] + ' '; @@ -22965,7 +23145,7 @@ function grammarPrinter(raw, options) { grammar_pre.push(_line); if (_entry5.length === 2) { - delete _src13[_i15]; + delete _src13[_i18]; } else { _clean2 = false; } @@ -22982,8 +23162,8 @@ function grammarPrinter(raw, options) { if (_src14) { var _clean3 = true; - for (var _i16 = 0, _len9 = _src14.length; _i16 < _len9; _i16++) { - var _entry6 = _src14[_i16]; + for (var _i19 = 0, _len15 = _src14.length; _i19 < _len15; _i19++) { + var _entry6 = _src14[_i19]; var _line2 = '%token ' + _entry6.id; @@ -23006,7 +23186,7 @@ function grammarPrinter(raw, options) { delete _entry6.id; if (isEmptyObj(_entry6)) { - delete _src14[_i16]; + delete _src14[_i19]; } else { _clean3 = false; } @@ -23056,14 +23236,14 @@ function grammarPrinter(raw, options) { // dump the remainder as a comment: var _rem = JSON5__default['default'].stringify(raw, null, 2); - _out += rmCommonWS$4(_templateObject151(), _rem.replace(/\*\//g, '*\\/')); // delete raw; + _out += rmCommonWS$4(_templateObject153(), _rem.replace(/\*\//g, '*\\/')); // delete raw; } if (!options.showParser) { _out += lex_out_str; } else { _out += grammar_pre.join('\n') + '\n\n'; - _out += rmCommonWS$4(_templateObject152()); + _out += rmCommonWS$4(_templateObject154()); if (grammar_mid.length > 0) { _out += grammar_mid.join('\n') + '\n\n'; @@ -23078,7 +23258,7 @@ function grammarPrinter(raw, options) { return '// ' + line; }); - _out += rmCommonWS$4(_templateObject153(), _a2.join('\n')); + _out += rmCommonWS$4(_templateObject155(), _a2.join('\n')); } _out += ebnf_rules.join('\n\n') + '\n\n'; @@ -23087,7 +23267,7 @@ function grammarPrinter(raw, options) { } if (grammar_post.length > 0) { - _out += rmCommonWS$4(_templateObject154()) + grammar_post.join('\n') + '\n\n'; + _out += rmCommonWS$4(_templateObject156()) + grammar_post.join('\n') + '\n\n'; } } @@ -23096,7 +23276,7 @@ function grammarPrinter(raw, options) { return '// ' + line; }); - _out = rmCommonWS$4(_templateObject155(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 + _out = rmCommonWS$4(_templateObject157(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 raw = deepClone(originalInput); @@ -23233,8 +23413,8 @@ function mkStdOptions$1() { var opts = {}; //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - for (var _len10 = arguments.length, args = new Array(_len10), _key9 = 0; _key9 < _len10; _key9++) { - args[_key9] = arguments[_key9]; + for (var _len16 = arguments.length, args = new Array(_len16), _key10 = 0; _key10 < _len16; _key10++) { + args[_key10] = arguments[_key10]; } if (args[0] !== 'NODEFAULT') { @@ -24128,7 +24308,7 @@ generator.signalUnusedProductions = function () { assert__default['default'](p.handle); var rhs = p.handle; - for (var j = 0, _len11 = rhs.length; j < _len11; j++) { + for (var j = 0, _len17 = rhs.length; j < _len17; j++) { var sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); @@ -24373,8 +24553,8 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (var _i17 = 0; _i17 < rhs.length; _i17++) { - var _sym = rhs[_i17]; + for (var _i20 = 0; _i20 < rhs.length; _i20++) { + var _sym = rhs[_i20]; if (!bnf[_sym] && _sym.length <= maxlen) { addSymbol(_sym); @@ -24626,13 +24806,13 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (var _i18 = 0; _i18 < rhs.length; _i18++) { - if (rhs[_i18] === 'error') { + for (var _i21 = 0; _i21 < rhs.length; _i21++) { + if (rhs[_i21] === 'error') { hasErrorRecovery = true; } - assert__default['default'](bnf[rhs[_i18]] ? symbols_[rhs[_i18]] : true, 'all nonterminals must already exist in the symbol table'); - assert__default['default'](rhs[_i18] ? symbols_[rhs[_i18]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); + assert__default['default'](bnf[rhs[_i21]] ? symbols_[rhs[_i21]] : true, 'all nonterminals must already exist in the symbol table'); + assert__default['default'](rhs[_i21] ? symbols_[rhs[_i21]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); } } @@ -24646,23 +24826,23 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm var prec_symbols = []; var winning_symbol; - for (var _i19 = r.handle.length - 1; _i19 >= 0; _i19--) { - if (!(r.handle[_i19] in nonterminals) && r.handle[_i19] in operators) { + for (var _i22 = r.handle.length - 1; _i22 >= 0; _i22--) { + if (!(r.handle[_i22] in nonterminals) && r.handle[_i22] in operators) { var old_prec = r.precedence; - var new_prec = operators[r.handle[_i19]].precedence; + var new_prec = operators[r.handle[_i22]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { - prec_symbols.push(r.handle[_i19]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], this.symbol, handle[0]); + prec_symbols.push(r.handle[_i22]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], this.symbol, handle[0]); if (new_prec < old_prec) { - winning_symbol = r.handle[_i19]; + winning_symbol = r.handle[_i22]; } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { - prec_symbols.push(r.handle[_i19]); - winning_symbol = r.handle[_i19]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); + prec_symbols.push(r.handle[_i22]); + winning_symbol = r.handle[_i22]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; @@ -24753,7 +24933,7 @@ function preprocessActionCode(s) { var dqpos, sqpos, ccmtpos, cppcmtpos; var first = -1; - for (var _c2 = 0;; _c2++) { + for (var _c3 = 0;; _c3++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); // also look for remaining comments which contain quotes of any kind, @@ -25158,7 +25338,7 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.getInitCodeSection = function getInitCodeSection(section) { var rv = []; - for (var i = 0, _len12 = this.length; i < _len12; i++) { + for (var i = 0, _len18 = this.length; i < _len18; i++) { var m = this[i]; if (m.qualifier === section) { @@ -25176,11 +25356,11 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { var rv = []; - for (var i = 0, _len13 = this.length; i < _len13; i++) { + for (var i = 0, _len19 = this.length; i < _len19; i++) { var m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { - rv.push(rmCommonWS$5(_templateObject156(), m.qualifier, m.include, m.qualifier)); + rv.push(rmCommonWS$5(_templateObject158(), m.qualifier, m.include, m.qualifier)); this.__consumedInitCodeSlots__[i] = true; } } @@ -25365,13 +25545,13 @@ generator.buildProductionActions = function buildProductionActions() { } } - for (var _i20 = 0; _i20 < rhs.length; _i20++) { + for (var _i23 = 0; _i23 < rhs.length; _i23++) { // check for aliased names, e.g., id[alias] - var _rhs_i = aliased[_i20]; - addName(_rhs_i, _i20); + var _rhs_i = aliased[_i23]; + addName(_rhs_i, _i23); - if (_rhs_i !== rhs[_i20]) { - addName(rhs[_i20], _i20); + if (_rhs_i !== rhs[_i23]) { + addName(rhs[_i23], _i23); } } @@ -25723,6 +25903,13 @@ generator.buildProductionActions = function buildProductionActions() { default_action.push("// END of default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, ")")); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } + default_action.push('\n', action); } @@ -26710,12 +26897,12 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - out.push(rmCommonWS$5(_templateObject157(), moduleImportsAsCode, moduleNameAsCode.trim())); + out.push(rmCommonWS$5(_templateObject159(), moduleImportsAsCode, moduleNameAsCode.trim())); exportMain = 'main: yyExecMain,'; - invokeMain = rmCommonWS$5(_templateObject158()); + invokeMain = rmCommonWS$5(_templateObject160()); } - out.push(rmCommonWS$5(_templateObject159(), invokeMain, exportMain)); + out.push(rmCommonWS$5(_templateObject161(), invokeMain, exportMain)); var src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; @@ -26729,10 +26916,10 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - main = rmCommonWS$5(_templateObject160(), moduleImportsAsCode, moduleNameAsCode.trim()); + main = rmCommonWS$5(_templateObject162(), moduleImportsAsCode, moduleNameAsCode.trim()); } - var out = this.generateModule(opt) + rmCommonWS$5(_templateObject161(), moduleName, moduleName, moduleName, moduleName, main); + var out = this.generateModule(opt) + rmCommonWS$5(_templateObject163(), moduleName, moduleName, moduleName, moduleName, main); opt.exportSourceCode.all = out; return out; }; @@ -27122,9 +27309,9 @@ function expandParseArguments(parseFn, self) { var wsi2 = new Array(max_k_len + 1).join(' '); // generate the member assignment list for the `sharedState_yy` object which will store the `parseParams` for everyone to access - for (var _i21 = 0, _len14 = arglist.length; _i21 < _len14; _i21++) { - var _k = arglist[_i21]; - s += '\n' + ws + _k + ': ' + _k + (_i21 < _len14 - 1 ? ',' + wsi2.substr(0, max_k_len - _k.length - 1) : wsi2.substr(0, max_k_len - _k.length)) + ' // parseParams::' + _k; + for (var _i24 = 0, _len20 = arglist.length; _i24 < _len20; _i24++) { + var _k = arglist[_i24]; + s += '\n' + ws + _k + ': ' + _k + (_i24 < _len20 - 1 ? ',' + wsi2.substr(0, max_k_len - _k.length - 1) : wsi2.substr(0, max_k_len - _k.length)) + ' // parseParams::' + _k; } return s; @@ -27308,8 +27495,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { for (var i = 0, len = a.length; i < len; i++) { var k = a[i]; - var v = tbl[k]; - nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys + var _v13 = tbl[k]; + nt[_v13] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -27929,15 +28116,15 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var line = []; line.push('║'); - for (var _c3 in def_arr) { - var _key10 = clip(_c3, col_width); + for (var _c4 in def_arr) { + var _key11 = clip(_c4, col_width); var delta = clip('∆', col_delta_width); - line.push(_key10); + line.push(_key11); line.push('┊'); line.push(delta); line.push('║'); - track_prev4delta[_c3] = 10000000; + track_prev4delta[_c4] = 10000000; } report.push(line.join('')); @@ -27946,30 +28133,30 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio line = []; line.push('║'); - for (var _c4 in def_arr) { + for (var _c5 in def_arr) { var val = void 0, delta_val = void 0; - var tbl = def_arr[_c4]; + var tbl = def_arr[_c5]; if (tbl.length > i) { val = tbl[i] || 0; - delta_val = val - track_prev4delta[_c4]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: + delta_val = val - track_prev4delta[_c5]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: if (delta_val < 0) { delta_val = -val - 1; // so that absolute 0 becomes -1, so it can be recognized from delta=0 ('no change') } - track_prev4delta[_c4] = val; + track_prev4delta[_c5] = val; } else { val = '.'; delta_val = '.'; } - var _key11 = clip(val, col_width); + var _key12 = clip(val, col_width); var _delta = clip(delta_val, col_delta_width); - line.push(_key11); + line.push(_key12); line.push('┊'); line.push(_delta); line.push('║'); @@ -28108,18 +28295,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio for (var i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + var _v14 = col[i]; var j = void 0; for (j = i + 1; j < len; j++) { - if (col[j] !== v) { + if (col[j] !== _v14) { break; } } var runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; + var delta = col[i + 1] - _v14; var steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -28167,18 +28354,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { - rv.push(v); + rv.push(_v14); } else if (optimum_gain === gain[0]) { - rv.push('s', '[' + v + ', ' + runlength + ']'); + rv.push('s', '[' + _v14 + ', ' + runlength + ']'); i += runlength - 1; } else if (optimum_gain === gain[1]) { - rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); + rv.push('s', '[' + _v14 + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; } else { - rv.push(v); //assert(0); // should never get here! + rv.push(_v14); //assert(0); // should never get here! } if (optimum_gain > 0) { @@ -28244,7 +28431,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // default main method for generated commonjs modules -var commonJsMain = "\nfunction __jison_default_main__(args) {\n // When the parser comes with its own `main` function, then use that one:\n if (typeof exports.parser.main === 'function') {\n return exports.parser.main(args);\n }\n\n if (!args[1]) {\n console.log('Usage:', path.basename(args[0]) + ' FILE');\n process.exit(1);\n }\n const source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n const dst = exports.parser.parse(source);\n console.log('parser output:\\n\\n', {\n type: typeof dst,\n value: dst\n });\n try {\n console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2));\n } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ }\n let rv = 0;\n if (typeof dst === 'number' || typeof dst === 'boolean') {\n rv = dst;\n }\n return dst;\n}\n"; // --- END of commonJsMain chunk --- +var commonJsMain = "\nfunction __jison_default_main__(args) {\n // When the parser comes with its own `main` function, then use that one:\n if (typeof exports.parser.main === 'function') {\n return exports.parser.main(args);\n }\n\n if (!args[1]) {\n console.log('Usage:', path.basename(args[0]) + ' FILE');\n process.exit(1);\n }\n const source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n const dst = exports.parser.parse(source);\n console.log('parser output:\\n\\n', {\n type: typeof dst,\n value: dst\n });\n try {\n console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2));\n } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ }\n let rv = 0;\n if (typeof dst === 'number' || typeof dst === 'boolean') {\n rv = dst;\n }\n return dst;\n}\n"; // --- END of commonJsMain chunk --- var commonJsMainImports = "\nconst fs = require('fs');\nconst path = require('path');\n"; // debug mixin for LR parser generators @@ -28292,7 +28479,7 @@ var parser$4 = typal.beget(); generatorMixin.createParser = function createParser() { var sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5(_templateObject162(), sourceCodeDef.init, sourceCodeDef.src); + var sourcecode = rmCommonWS$5(_templateObject164(), sourceCodeDef.init, sourceCodeDef.src); var p = code_exec$1(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { //console.log("===============================PARSER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$3(sourcecode); @@ -29068,7 +29255,7 @@ function getCommandlineOptions() { return v; }, - help: rmCommonWS$6(_templateObject163(), defaults.defaultActionMode.join(',')) + help: rmCommonWS$6(_templateObject165(), defaults.defaultActionMode.join(',')) }, hasTryCatch: { full: 'try-catch', diff --git a/dist/cli-cjs.js b/dist/cli-cjs.js index 011927744..7a7370988 100644 --- a/dist/cli-cjs.js +++ b/dist/cli-cjs.js @@ -2811,20 +2811,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2834,6 +2835,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2983,6 +2985,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2991,9 +2994,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -3040,6 +3043,7 @@ case 8: break; } } + } break; case 9: @@ -3124,8 +3128,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -3133,6 +3138,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -3163,8 +3169,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -3172,6 +3179,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -3202,9 +3210,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3216,6 +3225,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -3241,8 +3251,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3263,8 +3271,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3279,6 +3288,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3289,11 +3299,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3338,10 +3350,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3370,6 +3383,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3403,10 +3417,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3428,8 +3443,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3445,6 +3460,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3456,9 +3472,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3472,6 +3489,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3684,9 +3702,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3698,6 +3717,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3721,8 +3741,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3733,6 +3753,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3743,13 +3764,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3779,6 +3801,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3944,8 +3967,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3955,6 +3979,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3965,7 +3990,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3983,7 +4009,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3998,6 +4024,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -4243,9 +4270,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4273,6 +4301,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4284,8 +4313,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4300,6 +4330,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4310,6 +4341,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4364,13 +4396,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4658,10 +4691,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4672,8 +4707,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4684,6 +4721,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4694,7 +4732,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4711,6 +4749,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4806,7 +4845,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4819,6 +4859,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4829,6 +4870,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$2(yyvstack[yysp]); @@ -4837,7 +4879,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4854,6 +4896,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4864,11 +4907,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4882,6 +4926,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4925,9 +4970,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4938,6 +4984,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4989,9 +5036,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -5005,6 +5053,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -5015,8 +5064,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -5027,6 +5076,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -5050,10 +5100,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -5082,11 +5133,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -5098,6 +5149,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -10247,21 +10299,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10355,55 +10408,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10411,24 +10464,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10456,44 +10510,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10618,38 +10673,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10689,29 +10745,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10815,49 +10872,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10871,7 +10935,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11448,9 +11513,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11459,9 +11524,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11469,7 +11534,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11479,11 +11544,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11499,15 +11564,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11567,11 +11632,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$2 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$2 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11612,11 +11677,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11626,7 +11691,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11635,10 +11700,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11648,7 +11713,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11661,7 +11726,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11683,35 +11748,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11725,19 +11790,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11768,7 +11833,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -13154,7 +13219,13 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; - routingCode.push([].concat('case', i, ':', code, '{\n', action, '\n}\nbreak;').join(' ')); + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } + routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } if (simple_rule_count) { @@ -20873,8 +20944,6 @@ case 4: /*! Production:: optional_end_block : %epsilon */ case 101: /*! Production:: suffix : %epsilon */ -case 117: - /*! Production:: action : %epsilon */ case 118: /*! Production:: action_body : %epsilon */ case 133: @@ -20896,7 +20965,8 @@ case 5: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} @@ -20906,6 +20976,7 @@ case 5: `); } this.$ = yyvstack[yysp]; + } break; case 6: @@ -20931,8 +21002,9 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -20942,6 +21014,7 @@ case 8: `); } yy.addDeclaration(this.$, { actionInclude: yyvstack[yysp] }); + } break; case 9: @@ -21025,7 +21098,8 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action code block does not compile: ${rv} @@ -21035,6 +21109,7 @@ case 16: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 17: @@ -21045,7 +21120,8 @@ case 17: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -21055,6 +21131,7 @@ case 17: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 18: @@ -21181,7 +21258,8 @@ case 27: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} @@ -21196,6 +21274,7 @@ case 27: include: yyvstack[yysp] } }; + } break; case 28: @@ -21311,8 +21390,6 @@ case 113: /*! Production:: action_ne : ACTION */ case 114: /*! Production:: action_ne : include_macro_code */ -case 115: - /*! Production:: action : action_ne */ case 119: /*! Production:: action_body : action_comments_body */ case 123: @@ -21612,17 +21689,19 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = {id: id}; + { + let rv = []; + let lst = yyvstack[yysp]; + for (let i = 0, len = lst.length; i < len; i++) { + let id = lst[i]; + let m = {id: id}; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } rv.push(m); } this.$ = rv; + } break; case 62: @@ -21633,11 +21712,13 @@ case 62: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + let m = yyvstack[yysp]; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } this.$ = [m]; + } break; case 63: @@ -21915,18 +21996,37 @@ case 87: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { this.$ = [(yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '')]; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { @@ -21942,6 +22042,7 @@ case 87: if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 88: @@ -21952,22 +22053,42 @@ case 88: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = ['']; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - epsilon production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + epsilon production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + epsilon production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 89: @@ -22148,6 +22269,8 @@ case 106: case 107: /*! Production:: prec : %epsilon */ +case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); @@ -22174,6 +22297,20 @@ case 112: `); break; +case 115: + /*! Production:: action : action_ne */ + + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; + break; + case 116: /*! Production:: action : ARROW_ACTION */ @@ -22182,7 +22319,17 @@ case 116: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + let src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: ` + this.$ = ( + ${src} + ); + `, + isArrowAction: true + }; + } break; case 120: @@ -22243,8 +22390,9 @@ case 127: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); - var rv = checkActionBlock$2(fileContent); + { + let fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); + let rv = checkActionBlock$2(fileContent); if (rv) { yyparser.yyError(rmCommonWS$3` included action code file "${$PATH}" does not compile: ${rv} @@ -22255,6 +22403,7 @@ case 127: } // And no, we don't support nested '%include': this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -27470,42 +27619,48 @@ var lexer$2 = function() { case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ /*! Rule:: . */ @@ -28039,13 +28194,13 @@ var lexer$2 = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; // unescape a string value which is wrapped in quotes/doublequotes function unescQuote(str) { str = '' + str; - var a = str.split('\\\\'); + let a = str.split('\\\\'); a = a.map(function(s) { return s.replace(/\\'/g, '\'').replace(/\\"/g, '"'); @@ -28081,9 +28236,10 @@ var ebnf = false; -var rmCommonWS$3 = helpers.rmCommonWS; -var dquote$2 = helpers.dquote; -var checkActionBlock$2 = helpers.checkActionBlock; +const rmCommonWS$3 = helpers.rmCommonWS; +const dquote$2 = helpers.dquote; +const checkActionBlock$2 = helpers.checkActionBlock; +const trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary @@ -28114,7 +28270,7 @@ function parseValue$1(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -35277,9 +35433,9 @@ function __jison_default_main__(args) { try { console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2)); } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ } - let rv = 0; - if (typeof dst === 'number' || typeof dst === 'boolean') { - rv = dst; + let rv = 0; + if (typeof dst === 'number' || typeof dst === 'boolean') { + rv = dst; } return dst; } diff --git a/dist/cli-es6.js b/dist/cli-es6.js index 17fe453c7..e2b1d1400 100644 --- a/dist/cli-es6.js +++ b/dist/cli-es6.js @@ -2796,20 +2796,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2819,6 +2820,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2968,6 +2970,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2976,9 +2979,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -3025,6 +3028,7 @@ case 8: break; } } + } break; case 9: @@ -3109,8 +3113,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -3118,6 +3123,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -3148,8 +3154,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -3157,6 +3164,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -3187,9 +3195,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3201,6 +3210,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -3226,8 +3236,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3248,8 +3256,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3264,6 +3273,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3274,11 +3284,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3323,10 +3335,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3355,6 +3368,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3388,10 +3402,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3413,8 +3428,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3430,6 +3445,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3441,9 +3457,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3457,6 +3474,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3669,9 +3687,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3683,6 +3702,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3706,8 +3726,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3718,6 +3738,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3728,13 +3749,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3764,6 +3786,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3929,8 +3952,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3940,6 +3964,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3950,7 +3975,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3968,7 +3994,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3983,6 +4009,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -4228,9 +4255,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4258,6 +4286,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4269,8 +4298,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4285,6 +4315,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4295,6 +4326,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4349,13 +4381,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp('\\w[\\w\\d]*$'); + let re = new XRegExp('\\w[\\w\\d]*$'); if (XRegExp.match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4643,10 +4676,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4657,8 +4692,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4669,6 +4706,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4679,7 +4717,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4696,6 +4734,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4791,7 +4830,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4804,6 +4844,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4814,6 +4855,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$2(yyvstack[yysp]); @@ -4822,7 +4864,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4839,6 +4881,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4849,11 +4892,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4867,6 +4911,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4910,9 +4955,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4923,6 +4969,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4974,9 +5021,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4990,6 +5038,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -5000,8 +5049,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -5012,6 +5061,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -5035,10 +5085,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -5067,11 +5118,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -5083,6 +5134,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -10232,21 +10284,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10340,55 +10393,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10396,24 +10449,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10441,44 +10495,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10603,38 +10658,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10674,29 +10730,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10800,49 +10857,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10856,7 +10920,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11433,9 +11498,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11444,9 +11509,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11454,7 +11519,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11464,11 +11529,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11484,15 +11549,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11552,11 +11617,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$2 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$2 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11597,11 +11662,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11611,7 +11676,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11620,10 +11685,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11633,7 +11698,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11646,7 +11711,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11668,35 +11733,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11710,19 +11775,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11753,7 +11818,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -13139,6 +13204,12 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } @@ -20858,8 +20929,6 @@ case 4: /*! Production:: optional_end_block : %epsilon */ case 101: /*! Production:: suffix : %epsilon */ -case 117: - /*! Production:: action : %epsilon */ case 118: /*! Production:: action_body : %epsilon */ case 133: @@ -20881,7 +20950,8 @@ case 5: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} @@ -20891,6 +20961,7 @@ case 5: `); } this.$ = yyvstack[yysp]; + } break; case 6: @@ -20916,8 +20987,9 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -20927,6 +20999,7 @@ case 8: `); } yy.addDeclaration(this.$, { actionInclude: yyvstack[yysp] }); + } break; case 9: @@ -21010,7 +21083,8 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action code block does not compile: ${rv} @@ -21020,6 +21094,7 @@ case 16: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 17: @@ -21030,7 +21105,8 @@ case 17: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -21040,6 +21116,7 @@ case 17: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 18: @@ -21166,7 +21243,8 @@ case 27: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} @@ -21181,6 +21259,7 @@ case 27: include: yyvstack[yysp] } }; + } break; case 28: @@ -21296,8 +21375,6 @@ case 113: /*! Production:: action_ne : ACTION */ case 114: /*! Production:: action_ne : include_macro_code */ -case 115: - /*! Production:: action : action_ne */ case 119: /*! Production:: action_body : action_comments_body */ case 123: @@ -21597,17 +21674,19 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = {id: id}; + { + let rv = []; + let lst = yyvstack[yysp]; + for (let i = 0, len = lst.length; i < len; i++) { + let id = lst[i]; + let m = {id: id}; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } rv.push(m); } this.$ = rv; + } break; case 62: @@ -21618,11 +21697,13 @@ case 62: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + let m = yyvstack[yysp]; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } this.$ = [m]; + } break; case 63: @@ -21900,18 +21981,37 @@ case 87: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { this.$ = [(yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '')]; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { @@ -21927,6 +22027,7 @@ case 87: if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 88: @@ -21937,22 +22038,42 @@ case 88: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = ['']; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - epsilon production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + epsilon production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + epsilon production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 89: @@ -22133,6 +22254,8 @@ case 106: case 107: /*! Production:: prec : %epsilon */ +case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); @@ -22159,6 +22282,20 @@ case 112: `); break; +case 115: + /*! Production:: action : action_ne */ + + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; + break; + case 116: /*! Production:: action : ARROW_ACTION */ @@ -22167,7 +22304,17 @@ case 116: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + let src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: ` + this.$ = ( + ${src} + ); + `, + isArrowAction: true + }; + } break; case 120: @@ -22228,8 +22375,9 @@ case 127: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs.readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); - var rv = checkActionBlock$2(fileContent); + { + let fileContent = fs.readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); + let rv = checkActionBlock$2(fileContent); if (rv) { yyparser.yyError(rmCommonWS$3` included action code file "${$PATH}" does not compile: ${rv} @@ -22240,6 +22388,7 @@ case 127: } // And no, we don't support nested '%include': this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -27455,42 +27604,48 @@ var lexer$2 = function() { case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ /*! Rule:: . */ @@ -28024,13 +28179,13 @@ var lexer$2 = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; // unescape a string value which is wrapped in quotes/doublequotes function unescQuote(str) { str = '' + str; - var a = str.split('\\\\'); + let a = str.split('\\\\'); a = a.map(function(s) { return s.replace(/\\'/g, '\'').replace(/\\"/g, '"'); @@ -28066,9 +28221,10 @@ var ebnf = false; -var rmCommonWS$3 = helpers.rmCommonWS; -var dquote$2 = helpers.dquote; -var checkActionBlock$2 = helpers.checkActionBlock; +const rmCommonWS$3 = helpers.rmCommonWS; +const dquote$2 = helpers.dquote; +const checkActionBlock$2 = helpers.checkActionBlock; +const trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary @@ -28099,7 +28255,7 @@ function parseValue$1(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -31843,6 +31999,12 @@ generator.buildProductionActions = function buildProductionActions() { default_action.push(`// END of default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags})`); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } default_action.push('\n', action); } action = default_action.join('\n'); @@ -35256,9 +35418,9 @@ function __jison_default_main__(args) { try { console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2)); } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ } - let rv = 0; - if (typeof dst === 'number' || typeof dst === 'boolean') { - rv = dst; + let rv = 0; + if (typeof dst === 'number' || typeof dst === 'boolean') { + rv = dst; } return dst; } diff --git a/dist/cli-umd-es5.js b/dist/cli-umd-es5.js index e40e318b3..06e23fa97 100644 --- a/dist/cli-umd-es5.js +++ b/dist/cli-umd-es5.js @@ -3,9 +3,29 @@ "use strict"; -function _templateObject163() { +function _templateObject165() { var data = _taggedTemplateLiteral(["\n Specify the kind of default action that jison should include for every parser rule.\n\n You can specify a mode for *value handling* (\"$$\") and one for *location tracking* (\"@$\"), separated by a comma, e.g.:\n --default-action=ast,none\n\n Supported value modes:\n - classic : generate a parser which includes the default\n $$ = $1;\n action for every rule.\n - ast : generate a parser which produces a simple AST-like tree-of-arrays structure: every rule produces an array of its production terms' values. Otherwise it is identical to \"classic\" mode.\n - none : JISON will produce a slightly faster parser but then you are solely responsible for propagating rule action \"$$\" results. The default rule value is still deterministic though as it is set to \"undefined\": \"$$ = undefined;\"\n - skip : same as \"none\" mode, except JISON does NOT INJECT a default value action ANYWHERE, hence rule results are not deterministic when you do not properly manage the \"$$\" value yourself!\n\n Supported location modes:\n - merge : generate a parser which includes the default \"@$ = merged(@1..@n);\" location tracking action for every rule, i.e. the rule's production 'location' is the range spanning its terms.\n - classic : same as \"merge\" mode.\n - ast : ditto.\n - none : JISON will produce a slightly faster parser but then you are solely responsible for propagating rule action \"@$\" location results. The default rule location is still deterministic though, as it is set to \"undefined\": \"@$ = undefined;\"\n - skip : same as \"none\" mode, except JISON does NOT INJECT a default location action ANYWHERE, hence rule location results are not deterministic when you do not properly manage the \"@$\" value yourself!\n\n Notes:\n - when you do specify a value default mode, but DO NOT specify a location value mode, the latter is assumed to be the same as the former. Hence:\n --default-action=ast\n equals:\n --default-action=ast,ast\n - when you do not specify an explicit default mode or only a \"true\"/\"1\" value, the default is assumed: \"", "\".\n - when you specify \"false\"/\"0\" as an explicit default mode, \"none,none\" is assumed. This produces the fastest deterministic parser.\n "], ["\n Specify the kind of default action that jison should include for every parser rule.\n\n You can specify a mode for *value handling* (\"$$\") and one for *location tracking* (\"@$\"), separated by a comma, e.g.:\n --default-action=ast,none\n\n Supported value modes:\n - classic : generate a parser which includes the default\n $$ = $1;\n action for every rule.\n - ast : generate a parser which produces a simple AST-like tree-of-arrays structure: every rule produces an array of its production terms' values. Otherwise it is identical to \"classic\" mode.\n - none : JISON will produce a slightly faster parser but then you are solely responsible for propagating rule action \"$$\" results. The default rule value is still deterministic though as it is set to \"undefined\": \"$$ = undefined;\"\n - skip : same as \"none\" mode, except JISON does NOT INJECT a default value action ANYWHERE, hence rule results are not deterministic when you do not properly manage the \"$$\" value yourself!\n\n Supported location modes:\n - merge : generate a parser which includes the default \"@$ = merged(@1..@n);\" location tracking action for every rule, i.e. the rule\\'s production \\'location\\' is the range spanning its terms.\n - classic : same as \"merge\" mode.\n - ast : ditto.\n - none : JISON will produce a slightly faster parser but then you are solely responsible for propagating rule action \"@$\" location results. The default rule location is still deterministic though, as it is set to \"undefined\": \"@$ = undefined;\"\n - skip : same as \"none\" mode, except JISON does NOT INJECT a default location action ANYWHERE, hence rule location results are not deterministic when you do not properly manage the \"@$\" value yourself!\n\n Notes:\n - when you do specify a value default mode, but DO NOT specify a location value mode, the latter is assumed to be the same as the former. Hence:\n --default-action=ast\n equals:\n --default-action=ast,ast\n - when you do not specify an explicit default mode or only a \"true\"/\"1\" value, the default is assumed: \"", "\".\n - when you specify \"false\"/\"0\" as an explicit default mode, \"none,none\" is assumed. This produces the fastest deterministic parser.\n "]); + _templateObject165 = function _templateObject165() { + return data; + }; + + return data; +} + +function _templateObject164() { + var data = _taggedTemplateLiteral(["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the `eval()` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "], ["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the \\`eval()\\` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "]); + + _templateObject164 = function _templateObject164() { + return data; + }; + + return data; +} + +function _templateObject163() { + var data = _taggedTemplateLiteral(["\n\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.parser = ", ";\n exports.Parser = ", ".Parser;\n exports.parse = function () {\n return ", ".parse.apply(", ", arguments);\n };\n ", "\n }\n "]); + _templateObject163 = function _templateObject163() { return data; }; @@ -14,7 +34,7 @@ function _templateObject163() { } function _templateObject162() { - var data = _taggedTemplateLiteral(["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the `eval()` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "], ["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the \\`eval()\\` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "]); + var data = _taggedTemplateLiteral(["\n\n ", "\n\n exports.main = ", ";\n\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n exports.main(process.argv.slice(1));\n }\n "]); _templateObject162 = function _templateObject162() { return data; @@ -24,7 +44,7 @@ function _templateObject162() { } function _templateObject161() { - var data = _taggedTemplateLiteral(["\n\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.parser = ", ";\n exports.Parser = ", ".Parser;\n exports.parse = function () {\n return ", ".parse.apply(", ", arguments);\n };\n ", "\n }\n "]); + var data = _taggedTemplateLiteral(["\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser;\n parser.Parser = Parser;\n\n function yyparse() {\n return parser.parse.apply(parser, arguments);\n }\n\n ", "\n\n export default {\n parser,\n Parser,\n parse: yyparse,\n ", "\n };\n "]); _templateObject161 = function _templateObject161() { return data; @@ -34,7 +54,7 @@ function _templateObject161() { } function _templateObject160() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n exports.main = ", ";\n\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n exports.main(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n yyExecMain();\n }\n "]); _templateObject160 = function _templateObject160() { return data; @@ -44,7 +64,7 @@ function _templateObject160() { } function _templateObject159() { - var data = _taggedTemplateLiteral(["\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser;\n parser.Parser = Parser;\n\n function yyparse() {\n return parser.parse.apply(parser, arguments);\n }\n\n ", "\n\n export default {\n parser,\n Parser,\n parse: yyparse,\n ", "\n };\n "]); + var data = _taggedTemplateLiteral(["\n\n ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); _templateObject159 = function _templateObject159() { return data; @@ -54,7 +74,7 @@ function _templateObject159() { } function _templateObject158() { - var data = _taggedTemplateLiteral(["\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n yyExecMain();\n }\n "]); + var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); _templateObject158 = function _templateObject158() { return data; @@ -64,7 +84,7 @@ function _templateObject158() { } function _templateObject157() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // The JISON ", " has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END -----------------------------\n //\n\n "]); _templateObject157 = function _templateObject157() { return data; @@ -74,7 +94,7 @@ function _templateObject157() { } function _templateObject156() { - var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject156 = function _templateObject156() { return data; @@ -84,7 +104,7 @@ function _templateObject156() { } function _templateObject155() { - var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // The JISON ", " has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END -----------------------------\n //\n\n "]); + var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // This is a EBNF grammar. The resulting **BNF** grammar has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END OF BNF grammar --------------\n //\n\n\n "]); _templateObject155 = function _templateObject155() { return data; @@ -94,7 +114,7 @@ function _templateObject155() { } function _templateObject154() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject154 = function _templateObject154() { return data; @@ -104,7 +124,7 @@ function _templateObject154() { } function _templateObject153() { - var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // This is a EBNF grammar. The resulting **BNF** grammar has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END OF BNF grammar --------------\n //\n\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject153 = function _templateObject153() { return data; @@ -114,7 +134,7 @@ function _templateObject153() { } function _templateObject152() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n // ============================== START lexer section =========================== \n \n %lex\n \n ", "\n\n /lex\n\n // ============================== END lexer section =============================\n\n "]); _templateObject152 = function _templateObject152() { return data; @@ -124,7 +144,7 @@ function _templateObject152() { } function _templateObject151() { - var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject151 = function _templateObject151() { return data; @@ -134,7 +154,7 @@ function _templateObject151() { } function _templateObject150() { - var data = _taggedTemplateLiteral(["\n // ============================== START lexer section =========================== \n \n %lex\n \n ", "\n\n /lex\n\n // ============================== END lexer section =============================\n\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject150 = function _templateObject150() { return data; @@ -144,7 +164,7 @@ function _templateObject150() { } function _templateObject149() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject149 = function _templateObject149() { return data; @@ -154,7 +174,7 @@ function _templateObject149() { } function _templateObject148() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject148 = function _templateObject148() { return data; @@ -164,7 +184,7 @@ function _templateObject148() { } function _templateObject147() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject147 = function _templateObject147() { return data; @@ -174,7 +194,7 @@ function _templateObject147() { } function _templateObject146() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n // options:\n "]); _templateObject146 = function _templateObject146() { return data; @@ -184,7 +204,7 @@ function _templateObject146() { } function _templateObject145() { - var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject145 = function _templateObject145() { return data; @@ -194,7 +214,7 @@ function _templateObject145() { } function _templateObject144() { - var data = _taggedTemplateLiteral(["\n // options:\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject144 = function _templateObject144() { return data; @@ -204,7 +224,7 @@ function _templateObject144() { } function _templateObject143() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); _templateObject143 = function _templateObject143() { return data; @@ -214,7 +234,7 @@ function _templateObject143() { } function _templateObject142() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n // macros:\n "]); _templateObject142 = function _templateObject142() { return data; @@ -224,7 +244,7 @@ function _templateObject142() { } function _templateObject141() { - var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); + var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); _templateObject141 = function _templateObject141() { return data; @@ -234,7 +254,7 @@ function _templateObject141() { } function _templateObject140() { - var data = _taggedTemplateLiteral(["\n // macros:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); _templateObject140 = function _templateObject140() { return data; @@ -244,7 +264,7 @@ function _templateObject140() { } function _templateObject139() { - var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); _templateObject139 = function _templateObject139() { return data; @@ -264,7 +284,7 @@ function _templateObject138() { } function _templateObject137() { - var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); _templateObject137 = function _templateObject137() { return data; @@ -274,7 +294,7 @@ function _templateObject137() { } function _templateObject136() { - var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); _templateObject136 = function _templateObject136() { return data; @@ -294,7 +314,7 @@ function _templateObject135() { } function _templateObject134() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); _templateObject134 = function _templateObject134() { return data; @@ -304,7 +324,7 @@ function _templateObject134() { } function _templateObject133() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); _templateObject133 = function _templateObject133() { return data; @@ -324,7 +344,7 @@ function _templateObject132() { } function _templateObject131() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); _templateObject131 = function _templateObject131() { return data; @@ -334,7 +354,7 @@ function _templateObject131() { } function _templateObject130() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); _templateObject130 = function _templateObject130() { return data; @@ -344,7 +364,7 @@ function _templateObject130() { } function _templateObject129() { - var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); _templateObject129 = function _templateObject129() { return data; @@ -354,7 +374,7 @@ function _templateObject129() { } function _templateObject128() { - var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject128 = function _templateObject128() { return data; @@ -364,7 +384,7 @@ function _templateObject128() { } function _templateObject127() { - var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); _templateObject127 = function _templateObject127() { return data; @@ -374,7 +394,7 @@ function _templateObject127() { } function _templateObject126() { - var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); _templateObject126 = function _templateObject126() { return data; @@ -384,7 +404,7 @@ function _templateObject126() { } function _templateObject125() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject125 = function _templateObject125() { return data; @@ -394,7 +414,7 @@ function _templateObject125() { } function _templateObject124() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); _templateObject124 = function _templateObject124() { return data; @@ -404,7 +424,7 @@ function _templateObject124() { } function _templateObject123() { - var data = _taggedTemplateLiteral(["\n %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %epsilon rule action declaration error?\n \n Erroneous area:\n ", "\n "]); _templateObject123 = function _templateObject123() { return data; @@ -414,7 +434,7 @@ function _templateObject123() { } function _templateObject122() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n epsilon production rule arrow action code block does not compile: ", "\n \n Please be aware that the reported compile error MAY be referring\n to the wrapper code which is added by JISON automatically when\n processing arrow actions: the entire action code chunk \n (including wrapper) is:\n \n ", "\n \n Erroneous area:\n ", "\n "]); _templateObject122 = function _templateObject122() { return data; @@ -424,7 +444,7 @@ function _templateObject122() { } function _templateObject121() { - var data = _taggedTemplateLiteral(["\n %epsilon rule action declaration error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n epsilon production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject121 = function _templateObject121() { return data; @@ -434,7 +454,7 @@ function _templateObject121() { } function _templateObject120() { - var data = _taggedTemplateLiteral(["\n epsilon production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n You cannot specify a precedence override for an epsilon (a.k.a. empty) rule!\n \n Erroneous area:\n ", "\n "]); _templateObject120 = function _templateObject120() { return data; @@ -444,7 +464,7 @@ function _templateObject120() { } function _templateObject119() { - var data = _taggedTemplateLiteral(["\n You cannot specify a precedence override for an epsilon (a.k.a. empty) rule!\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n production rule arrow action code block does not compile: ", "\n \n Please be aware that the reported compile error MAY be referring\n to the wrapper code which is added by JISON automatically when\n processing arrow actions: the entire action code chunk \n (including wrapper) is:\n \n ", "\n \n Erroneous area:\n ", "\n "]); _templateObject119 = function _templateObject119() { return data; @@ -454,7 +474,7 @@ function _templateObject119() { } function _templateObject118() { - var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject118 = function _templateObject118() { return data; @@ -4187,30 +4207,32 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { - this.$[key] = yyvstack[yysp - 2][key]; - } // if there are any options, add them all, otherwise set options to NULL: - // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: + for (var key in yyvstack[yysp - 2]) { + this.$[key] = yyvstack[yysp - 2][key]; + } // if there are any options, add them all, otherwise set options to NULL: + // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { - this.$.options = yy.options; - break; - } + for (var _key in yy.options) { + this.$.options = yy.options; + break; + } - if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: + if (yy.actionInclude) { + var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: - if (asrc.trim() !== '') { - this.$.actionInclude = asrc; + if (asrc.trim() !== '') { + this.$.actionInclude = asrc; + } } - } - delete yy.options; - delete yy.actionInclude; - return this.$; + delete yy.options; + delete yy.actionInclude; + return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -4314,50 +4336,51 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - if (yyvstack[yysp]) { - switch (yyvstack[yysp].type) { - case 'macro': - this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; - break; + if (yyvstack[yysp]) { + switch (yyvstack[yysp].type) { + case 'macro': + this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; + break; - case 'names': - var condition_defs = yyvstack[yysp].names; + case 'names': + var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + for (var i = 0, len = condition_defs.length; i < len; i++) { + var name = condition_defs[i][0]; - if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { - yyparser.yyError(rmCommonWS$1(_templateObject3(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); - } + if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { + yyparser.yyError(rmCommonWS$1(_templateObject3(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + } - this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' - } // and update the `yy.startConditions` hash table as well, so we have a full set - // by the time this parser arrives at the lexer rules in the input-to-parse: + this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' + } // and update the `yy.startConditions` hash table as well, so we have a full set + // by the time this parser arrives at the lexer rules in the input-to-parse: - yy.startConditions = this.$.startConditions; - break; + yy.startConditions = this.$.startConditions; + break; - case 'unknown': - this.$.unknownDecls.push(yyvstack[yysp].body); - break; + case 'unknown': + this.$.unknownDecls.push(yyvstack[yysp].body); + break; - case 'imports': - this.$.importDecls.push(yyvstack[yysp].body); - break; + case 'imports': + this.$.importDecls.push(yyvstack[yysp].body); + break; - case 'codeSection': - this.$.codeSections.push(yyvstack[yysp].body); - break; + case 'codeSection': + this.$.codeSections.push(yyvstack[yysp].body); + break; - default: - yyparser.yyError(rmCommonWS$1(_templateObject4(), yyvstack[yysp].type, yylexer.prettyPrintRange(yylstack[yysp]))); - break; + default: + yyparser.yyError(rmCommonWS$1(_templateObject4(), yyvstack[yysp].type, yylexer.prettyPrintRange(yylstack[yysp]))); + break; + } } } - break; case 9: @@ -4417,17 +4440,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 0; // flag as 'inclusive' - } + for (var _i3 = 0, _len2 = lst.length; _i3 < _len2; _i3++) { + lst[_i3][1] = 0; // flag as 'inclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 13: @@ -4444,17 +4469,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var _lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 1; // flag as 'exclusive' - } + for (var _i4 = 0, _len3 = _lst.length; _i4 < _len3; _i4++) { + _lst[_i4][1] = 1; // flag as 'exclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: _lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 15: @@ -4471,19 +4498,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (srcCode) { + var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject9(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + if (rv) { + yyparser.yyError(rmCommonWS$1(_templateObject9(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + + yy.actionInclude.push(srcCode); } - yy.actionInclude.push(srcCode); + this.$ = null; } - - this.$ = null; break; case 17: @@ -4504,8 +4533,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; yyparser.yyError(rmCommonWS$1(_templateObject10(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); this.$ = null; break; @@ -4515,10 +4542,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject11(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = null; + { + var start_marker = yyvstack[yysp - 1].trim(); + var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + yyparser.yyError(rmCommonWS$1(_templateObject11(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = null; + } break; case 20: @@ -4526,13 +4555,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var _lst2 = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - yy.options[lst[i][0]] = lst[i][1]; - } + for (var _i5 = 0, _len4 = _lst2.length; _i5 < _len4; _i5++) { + yy.options[_lst2[_i5][0]] = _lst2[_i5][1]; + } - this.$ = null; + this.$ = null; + } break; case 21: @@ -4559,28 +4590,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Production:: definition : import_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + { + // check if there are two unvalued options: 'name path' + var _lst3 = yyvstack[yysp - 1]; + var _len5 = _lst3.length; + var body; + + if (_len5 === 2 && _lst3[0][1] === true && _lst3[1][1] === true) { + // `name path`: + body = { + name: _lst3[0][0], + path: _lst3[1][0] + }; + } else if (_len5 <= 2) { + yyparser.yyError(rmCommonWS$1(_templateObject13(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject14(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } - if (len === 2 && lst[0][1] === true && lst[1][1] === true) { - // `name path`: - body = { - name: lst[0][0], - path: lst[1][0] + this.$ = { + type: 'imports', + body: body }; - } else if (len <= 2) { - yyparser.yyError(rmCommonWS$1(_templateObject13(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject14(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); } - - this.$ = { - type: 'imports', - body: body - }; break; case 24: @@ -4596,35 +4629,39 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) - // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + { + // check there's only 1 option which is an identifier + var _lst4 = yyvstack[yysp - 4]; + var _len6 = _lst4.length; - if (len === 1 && lst[0][1] === true) { - // `name`: - name = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1(_templateObject16(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject17(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); - } + var _name; - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + if (_len6 === 1 && _lst4[0][1] === true) { + // `name`: + _name = _lst4[0][0]; + } else if (_len6 <= 1) { + yyparser.yyError(rmCommonWS$1(_templateObject16(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject17(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); + } - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject18(), name, rv, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5]))); - } + var _srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - this.$ = { - type: 'codeSection', - body: { - qualifier: name, - include: srcCode + var _rv = checkActionBlock$1(_srcCode, yylstack[yysp - 2], yy); + + if (_rv) { + yyparser.yyError(rmCommonWS$1(_templateObject18(), _name, _rv, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5]))); } - }; + + this.$ = { + type: 'codeSection', + body: { + qualifier: _name, + include: _srcCode + } + }; + } break; case 26: @@ -4633,10 +4670,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - var end_marker_msg = marker_msg.replace(/\{/g, '}'); - yyparser.yyError(rmCommonWS$1(_templateObject19(), marker_msg, end_marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 4]), yyvstack[yysp - 1].errStr)); + { + var _start_marker = yyvstack[yysp - 2].trim(); + + var _marker_msg = _start_marker ? ' or similar, such as ' + _start_marker : ''; + + var end_marker_msg = _marker_msg.replace(/\{/g, '}'); + + yyparser.yyError(rmCommonWS$1(_templateObject19(), _marker_msg, end_marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 4]), yyvstack[yysp - 1].errStr)); + } break; case 27: @@ -4770,19 +4812,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var _srcCode2 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (_srcCode2) { + var _rv2 = checkActionBlock$1(_srcCode2, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject23(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + if (_rv2) { + yyparser.yyError(rmCommonWS$1(_templateObject23(), _rv2, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + + yy.actionInclude.push(_srcCode2); } - yy.actionInclude.push(srcCode); + this.$ = yyvstack[yysp - 3]; } - - this.$ = yyvstack[yysp - 3]; break; case 42: @@ -4800,10 +4844,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject24(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = yyvstack[yysp - 2]; + { + var _start_marker2 = yyvstack[yysp - 1].trim(); + + yyparser.yyError(rmCommonWS$1(_templateObject24(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -4811,20 +4857,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error - // is more probably due to indenting the rule regex, rather than an error - // in writing the action code block: + { + var _start_marker3 = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error + // is more probably due to indenting the rule regex, rather than an error + // in writing the action code block: - console.error("*** error! marker:", start_marker); - if (start_marker.indexOf('{') >= 0) { - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject25(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject26(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); - } + console.error("*** error! marker:", _start_marker3); - this.$ = yyvstack[yysp - 2]; + if (_start_marker3.indexOf('{') >= 0) { + var _marker_msg2 = _start_marker3 ? ' or similar, such as ' + _start_marker3 : ''; + + yyparser.yyError(rmCommonWS$1(_templateObject25(), _marker_msg2, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject26(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); + } + + this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -4932,14 +4982,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + var _srcCode3 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject31(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); - } + var _rv3 = checkActionBlock$1(_srcCode3, yylstack[yysp - 1], yy); + + if (_rv3) { + yyparser.yyError(rmCommonWS$1(_templateObject31(), _rv3, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); + } - this.$ = [yyvstack[yysp - 3], srcCode]; + this.$ = [yyvstack[yysp - 3], _srcCode3]; + } break; case 61: @@ -4947,31 +5000,34 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. - // - // Note/Optimization: - // there's no need for braces in the generated expression when we can - // already see the given action is an identifier string or something else - // that's a sure simple thing for a JavaScript `return` statement to carry. - // By doing this, we simplify the token return replacement code replacement - // process which will be applied to the parsed lexer before its code - // will be generated by JISON. - - if (/^[^\r\n;\/]+$/.test(srcCode)) { - srcCode = 'return ' + srcCode; - } else { - srcCode = 'return (' + srcCode + '\n)'; - } + { + var _srcCode4 = trimActionCode$1(yyvstack[yysp - 1]); // 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. + // + // Note/Optimization: + // there's no need for braces in the generated expression when we can + // already see the given action is an identifier string or something else + // that's a sure simple thing for a JavaScript `return` statement to carry. + // By doing this, we simplify the token return replacement code replacement + // process which will be applied to the parsed lexer before its code + // will be generated by JISON. - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject32(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); - } + if (/^[^\r\n;\/]+$/.test(_srcCode4)) { + _srcCode4 = 'return ' + _srcCode4; + } else { + _srcCode4 = 'return (' + _srcCode4 + '\n)'; + } + + var _rv4 = checkActionBlock$1(_srcCode4, yylstack[yysp - 1], yy); - this.$ = [yyvstack[yysp - 3], srcCode]; + if (_rv4) { + yyparser.yyError(rmCommonWS$1(_templateObject32(), _rv4, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); + } + + this.$ = [yyvstack[yysp - 3], _srcCode4]; + } break; case 62: @@ -5091,20 +5147,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; // Validate the given condition state: when it isn't known, print an error message - // accordingly: - - if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { - yyparser.yyError(rmCommonWS$1(_templateObject41(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp]))); - } + { + // rewrite + accept star '*' as name + check if we allow empty list? + this.$ = yyvstack[yysp - 2].map(function (el) { + var name = el[0]; // Validate the given condition state: when it isn't known, print an error message + // accordingly: - return name; - }); // '<' '*' '>' - // { $$ = ['*']; } + if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { + yyparser.yyError(rmCommonWS$1(_templateObject41(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp]))); + } + return name; + }); // '<' '*' '>' + // { $$ = ['*']; } + } break; case 74: @@ -5112,78 +5169,82 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { - return el[0]; - }); - yyparser.yyError(rmCommonWS$1(_templateObject42(), lst.join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + { + // rewrite + accept star '*' as name + check if we allow empty list? + var _lst5 = yyvstack[yysp - 1].map(function (el) { + return el[0]; + }); + + yyparser.yyError(rmCommonWS$1(_templateObject42(), _lst5.join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + } break; case 75: /*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // Detect if the regex ends with a pure (Unicode) word; - // we *do* consider escaped characters which are 'alphanumeric' - // to be equivalent to their non-escaped version, hence these are - // all valid 'words' for the 'easy keyword rules' option: - // - // - hello_kitty - // - γεια_σου_γατούλα - // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 - // - // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 - // - // As we only check the *tail*, we also accept these as - // 'easy keywords': - // - // - %options - // - %foo-bar - // - +++a:b:c1 - // - // Note the dash in that last example: there the code will consider - // `bar` to be the keyword, which is fine with us as we're only - // interested in the trailing boundary and patching that one for - // the `easy_keyword_rules` option. - - this.$ = yyvstack[yysp]; - - if (yy.options.easy_keyword_rules) { - // We need to 'protect' `eval` here as keywords are allowed - // to contain double-quotes and other leading cruft. - // `eval` *does* gobble some escapes (such as `\b`) but - // we protect against that through a simple replace regex: - // we're not interested in the special escapes' exact value - // anyway. - // It will also catch escaped escapes (`\\`), which are not - // word characters either, so no need to worry about - // `eval(str)` 'correctly' converting convoluted constructs - // like '\\\\\\\\\\b' in here. - this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); - - try { - // Convert Unicode escapes and other escapes to their literal characters - // BEFORE we go and check whether this item is subject to the - // `easy_keyword_rules` option. - this.$ = JSON.parse('"' + this.$ + '"'); - } catch (ex) { - yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: - - this.$ = '.'; - } // a 'keyword' starts with an alphanumeric character, - // followed by zero or more alphanumerics or digits: + { + // Detect if the regex ends with a pure (Unicode) word; + // we *do* consider escaped characters which are 'alphanumeric' + // to be equivalent to their non-escaped version, hence these are + // all valid 'words' for the 'easy keyword rules' option: + // + // - hello_kitty + // - γεια_σου_γατούλα + // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 + // + // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 + // + // As we only check the *tail*, we also accept these as + // 'easy keywords': + // + // - %options + // - %foo-bar + // - +++a:b:c1 + // + // Note the dash in that last example: there the code will consider + // `bar` to be the keyword, which is fine with us as we're only + // interested in the trailing boundary and patching that one for + // the `easy_keyword_rules` option. + this.$ = yyvstack[yysp]; - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); - - if (XRegExp__default['default'].match(this.$, re)) { - this.$ = yyvstack[yysp] + "\\b"; - } else { - this.$ = yyvstack[yysp]; + if (yy.options.easy_keyword_rules) { + // We need to 'protect' `eval` here as keywords are allowed + // to contain double-quotes and other leading cruft. + // `eval` *does* gobble some escapes (such as `\b`) but + // we protect against that through a simple replace regex: + // we're not interested in the special escapes' exact value + // anyway. + // It will also catch escaped escapes (`\\`), which are not + // word characters either, so no need to worry about + // `eval(str)` 'correctly' converting convoluted constructs + // like '\\\\\\\\\\b' in here. + this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); + + try { + // Convert Unicode escapes and other escapes to their literal characters + // BEFORE we go and check whether this item is subject to the + // `easy_keyword_rules` option. + this.$ = JSON.parse('"' + this.$ + '"'); + } catch (ex) { + yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: + + this.$ = '.'; + } // a 'keyword' starts with an alphanumeric character, + // followed by zero or more alphanumerics or digits: + + + var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + + if (XRegExp__default['default'].match(this.$, re)) { + this.$ = yyvstack[yysp] + "\\b"; + } else { + this.$ = yyvstack[yysp]; + } } } - break; case 76: @@ -5401,10 +5462,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; - this.$ = encodeRegexLiteralStr(s, edge); + { + var src = yyvstack[yysp]; + + var _s = src.substring(1, src.length - 1); + + var edge = src[0]; + this.$ = encodeRegexLiteralStr(_s, edge); + } break; case 112: @@ -5412,30 +5477,34 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; - this.$ = encodeRegexLiteralStr(s); + { + var _s2 = yyvstack[yysp]; + this.$ = encodeRegexLiteralStr(_s2); + } break; case 113: /*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal behaviour under the given circumstances, i.e. parser context: - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { - yyparser.yyError(rmCommonWS$1(_templateObject45(), yy.__options_category_description__, yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4]))); - } + { + // validate that this is legal behaviour under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { + yyparser.yyError(rmCommonWS$1(_templateObject45(), yy.__options_category_description__, yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4]))); + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { - return opt[0]; - }); - optlist.push(yyvstack[yysp][0]); - yyparser.yyError(rmCommonWS$1(_templateObject46(), yy.__options_category_description__, yyvstack[yysp - 4], optlist.join(' '), yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4]))); - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { + var optlist = yyvstack[yysp - 2].map(function (opt) { + return opt[0]; + }); + optlist.push(yyvstack[yysp][0]); + yyparser.yyError(rmCommonWS$1(_templateObject46(), yy.__options_category_description__, yyvstack[yysp - 4], optlist.join(' '), yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4]))); + } - this.$ = yyvstack[yysp - 2]; - this.$.push(yyvstack[yysp]); + this.$ = yyvstack[yysp - 2]; + this.$.push(yyvstack[yysp]); + } break; case 114: @@ -5497,60 +5566,64 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + var with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1(_templateObject50(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$1(_templateObject50(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]), yyvstack[yysp].errStr)); + } break; case 120: /*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - - if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { - this.$ = mkIdentifier$2(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; - // if not, report an error as we don't want confusion due to - // typos and/or garbage input here producing something that - // is usable from a machine perspective. - if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { + this.$ = mkIdentifier$2(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; + // if not, report an error as we don't want confusion due to + // typos and/or garbage input here producing something that + // is usable from a machine perspective. + + if (!isLegalIdentifierInput$1(yyvstack[yysp])) { + var _with_value_msg = ' (with optional value assignment)'; + + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + _with_value_msg = ''; + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; + yyparser.yyError(rmCommonWS$1(_templateObject51(), _with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } - - yyparser.yyError(rmCommonWS$1(_templateObject51(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } else { + this.$ = yyvstack[yysp]; } - } else { - this.$ = yyvstack[yysp]; } - break; case 121: /*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { - this.$ = yyvstack[yysp]; - } else { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { + this.$ = yyvstack[yysp]; + } else { + var _with_value_msg2 = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + _with_value_msg2 = ''; + } - yyparser.yyError(rmCommonWS$1(_templateObject52(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$1(_templateObject52(), _with_value_msg2, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } } - break; case 122: @@ -5582,17 +5655,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + var _srcCode5 = trimActionCode$1(yyvstack[yysp]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + if (_srcCode5) { + var _rv5 = checkActionBlock$1(_srcCode5, yylstack[yysp], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject53(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + if (_rv5) { + yyparser.yyError(rmCommonWS$1(_templateObject53(), _rv5, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } } - } - this.$ = srcCode; + this.$ = _srcCode5; + } break; case 126: @@ -5619,20 +5694,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var _srcCode6 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (_srcCode6) { + var _rv6 = checkActionBlock$1(_srcCode6, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject56(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); - } - } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) - // we append those protective double newlines right now, as the calling site - // won't do it for us: + if (_rv6) { + yyparser.yyError(rmCommonWS$1(_templateObject56(), _rv6, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) + // we append those protective double newlines right now, as the calling site + // won't do it for us: - this.$ = '\n\n' + srcCode + '\n\n'; + this.$ = '\n\n' + _srcCode6 + '\n\n'; + } break; case 131: @@ -5640,10 +5717,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject57(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = ''; + { + var _start_marker4 = yyvstack[yysp - 1].trim(); + + yyparser.yyError(rmCommonWS$1(_templateObject57(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = ''; + } break; case 133: @@ -5660,36 +5739,40 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) - // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + { + // check if there is only 1 unvalued options: 'path' + var _lst6 = yyvstack[yysp - 1]; + var _len7 = _lst6.length; + + var _path; - if (len === 1 && lst[0][1] === true) { - // `path`: - path = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1(_templateObject58(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject59(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); - } // **Aside**: And no, we don't support nested '%include'! + if (_len7 === 1 && _lst6[0][1] === true) { + // `path`: + _path = _lst6[0][0]; + } else if (_len7 <= 1) { + yyparser.yyError(rmCommonWS$1(_templateObject58(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject59(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); + } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { - encoding: 'utf-8' - }); - var srcCode = trimActionCode$1(fileContent); + var fileContent = fs__default['default'].readFileSync(_path, { + encoding: 'utf-8' + }); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + var _srcCode7 = trimActionCode$1(fileContent); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject60(), path, rv, yylexer.prettyPrintRange(this._$))); + if (_srcCode7) { + var _rv7 = checkActionBlock$1(_srcCode7, this._$, yy); + + if (_rv7) { + yyparser.yyError(rmCommonWS$1(_templateObject60(), _path, _rv7, yylexer.prettyPrintRange(this._$))); + } } - } - this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + this.$ = '\n// Included by Jison: ' + _path + ':\n\n' + _srcCode7 + '\n\n// End Of Include by Jison: ' + _path + '\n\n'; + } break; case 135: @@ -5879,12 +5962,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (recoveringErrorInfo) { var esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); - v.yyError = true; - v.errorRuleDepth = error_rule_depth; - v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; - recoveringErrorInfo.value_stack[esp] = v; + var _v = this.shallowCopyErrorInfo(hash); + + _v.yyError = true; + _v.errorRuleDepth = error_rule_depth; + _v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; + + recoveringErrorInfo.value_stack[esp] = _v; recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc); recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1]; ++esp; @@ -6009,8 +6094,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.__error_infos.length = 0; - for (var _i3 = this.__error_recovery_infos.length - 1; _i3 >= 0; _i3--) { - var _el = this.__error_recovery_infos[_i3]; + for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { + var _el = this.__error_recovery_infos[_i6]; if (_el && typeof _el.destroy === 'function') { _el.destroy(); @@ -6062,8 +6147,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l2) { if (last_index != null) { - for (var _i4 = i2; _i4 >= i1; _i4--) { - l2 = lstack[_i4]; + for (var _i7 = i2; _i7 >= i1; _i7--) { + l2 = lstack[_i7]; if (l2) { break; @@ -6076,8 +6161,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var _i5 = (i1 || sp) - 1; _i5 >= 0; _i5--) { - l1 = lstack[_i5]; + for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { + l1 = lstack[_i8]; if (l1) { break; @@ -8989,19 +9074,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; - var l = scanRegExp(yy_.yytext); + { + yy.include_command_allowed = false; + var l = scanRegExp(yy_.yytext); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); - yy_.yytext = yy_.yytext[0]; - } + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - return 35; + return 35; + } case 10: /*! Conditions:: action */ @@ -9089,65 +9176,67 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - yy.include_command_allowed = false; - this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - - var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + + var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + + var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + var atSOL = !precedingStr + /* @ Start Of File */ + || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + + var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - var prevEnd = 0; - var endMarkerIndex; + var remaining = this.lookAhead(); + var prevEnd = 0; + var endMarkerIndex; - for (;;) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + for (;;) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS(_templateObject65(), endMarker) + this.prettyPrintRange(yy_.yylloc)); - return 24; - } + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS(_templateObject65(), endMarker) + this.prettyPrintRange(yy_.yylloc)); + return 24; + } - break; - } // Allow the start marker to be re-matched by the generated lexer rule regex: + break; + } // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; - } + if (atSOL) { + return 22; + } - return 25; + return 25; + } case 20: /*! Conditions:: rules macro INITIAL */ @@ -9180,41 +9269,43 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); - - this.pushState('action'); // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - - var la = this.lookAhead(); - - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser - } + { + yy.depth = 0; + yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); + + this.pushState('action'); // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + + var la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - return 25; + return 25; + } case 24: /*! Conditions:: rules */ @@ -9371,32 +9462,39 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); - yy_.yytext = v; - } + { + var m = this.matches; + yy_.yytext = NaN; - return 43; + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + var _v2 = parseInt(m[1], 8); + + yy_.yytext = _v2; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + var _v3 = m[2].charCodeAt(0) - 64; + + yy_.yytext = _v3; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + var _v4 = parseInt(m[3], 16); + + yy_.yytext = _v4; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + var _v5 = parseInt(m[4], 16); + + yy_.yytext = _v5; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + var _v6 = parseInt(m[5], 16); + + yy_.yytext = _v6; + } + + return 43; + } case 70: /*! Conditions:: rules macro INITIAL */ @@ -9444,26 +9542,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; - yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; - this.pushState('action'); // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': + { + yy.depth = 0; + yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. - this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + var _precedingStr = this.matched[this.matched.length - this.match.length - 1]; - if (atSOL) { - return 22; - } + var _atSOL = !_precedingStr + /* @ Start Of File */ + || _precedingStr === '\n'; - return 25; + this.pushState('action'); // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + + this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + + if (_atSOL) { + return 22; + } + + return 25; + } case 81: /*! Conditions:: INITIAL rules code */ @@ -9554,35 +9656,45 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject73(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS(_templateObject73(), rules) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject74(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var _rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject74(), _rules) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject75(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var _rules2 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject75(), _rules2) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ + { + /* b0rk on bad characters */ + var _rules3 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject76(), rules, dquote(this.topState()), rules) + this.prettyPrintRange(yy_.yylloc)); - return 2; + yy_.yyerror(rmCommonWS(_templateObject76(), _rules3, dquote(this.topState()), _rules3) + this.prettyPrintRange(yy_.yylloc)); + return 2; + } case 104: /*! Conditions:: options */ @@ -10226,28 +10338,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + var _c = s[i]; - switch (c) { + switch (_c) { case '\\': i++; if (i < l) { - c = s[i]; + _c = s[i]; - if (c === edge) { - rv += c; + if (_c === edge) { + rv += _c; continue; } - var pos = '\'"`'.indexOf(c); + var _pos = '\'"`'.indexOf(_c); - if (pos >= 0) { - rv += '\\\\' + c; + if (_pos >= 0) { + rv += '\\\\' + _c; continue; } - if (c === '\\') { + if (_c === '\\') { rv += '\\\\'; continue; } @@ -10282,40 +10394,45 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); - rv += encodeCharCode(v); + var _v7 = parseInt(m[4], 8); + + rv += encodeCharCode(_v7); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; - rv += encodeCharCode(v); + var _v8 = m[5].charCodeAt(0) - 64; + + rv += encodeCharCode(_v8); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); - rv += encodeCharCode(v); + var _v9 = parseInt(m[6], 16); + + rv += encodeCharCode(_v9); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); - rv += encodeCharCode(v); + var _v10 = parseInt(m[7], 16); + + rv += encodeCharCode(_v10); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); - rv += encodeUnicodeCodepoint(v); + var _v11 = parseInt(m[8], 16); + + rv += encodeUnicodeCodepoint(_v11); i += m[8].length; continue; } @@ -10329,21 +10446,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + var pos = ".*+?^${}()|[]/\\".indexOf(_c); if (pos >= 0) { - rv += '\\' + c; + rv += '\\' + _c; continue; } - var cc = charCvtTable[c]; + var cc = charCvtTable[_c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = _c.charCodeAt(0); if (cc < 32) { var rvp = codeCvtTable[v]; @@ -10354,7 +10471,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi rv += "\\u" + ('0000' + cc.toString(16)).substr(-4); } } else { - rv += c; + rv += _c; } continue; @@ -11786,7 +11903,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi simple_rule_count++; caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { - regular_rule_count++; + regular_rule_count++; // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } + routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } @@ -12707,7 +12831,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var minl = Math.max(0, line - 10); var b = a.slice(minl, line + 10); - var _c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); + var _c2 = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); var offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2(_templateObject82(), ex, offendingChunk)); @@ -16995,9 +17119,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 101: /*! Production:: suffix : %epsilon */ - case 117: - /*! Production:: action : %epsilon */ - case 118: /*! Production:: action_body : %epsilon */ @@ -17014,13 +17135,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (rv) { + yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = yyvstack[yysp]; + this.$ = yyvstack[yysp]; + } break; case 6: @@ -17042,16 +17165,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + this.$ = yyvstack[yysp - 1]; - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject94(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + var _rv8 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - yy.addDeclaration(this.$, { - actionInclude: yyvstack[yysp] - }); + if (_rv8) { + yyparser.yyError(rmCommonWS$3(_templateObject94(), _rv8, yylexer.prettyPrintRange(yylstack[yysp]))); + } + + yy.addDeclaration(this.$, { + actionInclude: yyvstack[yysp] + }); + } break; case 9: @@ -17121,15 +17247,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var _rv9 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (_rv9) { + yyparser.yyError(rmCommonWS$3(_templateObject96(), _rv9, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = { - include: yyvstack[yysp] - }; + this.$ = { + include: yyvstack[yysp] + }; + } break; case 17: @@ -17137,15 +17265,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var _rv10 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject97(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (_rv10) { + yyparser.yyError(rmCommonWS$3(_templateObject97(), _rv10, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = { - include: yyvstack[yysp] - }; + this.$ = { + include: yyvstack[yysp] + }; + } break; case 18: @@ -17245,18 +17375,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); - } + { + var _rv11 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - this.$ = { - initCode: { - qualifier: yyvstack[yysp - 1], - include: yyvstack[yysp] + if (_rv11) { + yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, _rv11, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } - }; + + this.$ = { + initCode: { + qualifier: yyvstack[yysp - 1], + include: yyvstack[yysp] + } + }; + } break; case 28: @@ -17358,9 +17490,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 114: /*! Production:: action_ne : include_macro_code */ - case 115: - /*! Production:: action : action_ne */ - case 119: /*! Production:: action_body : action_comments_body */ @@ -17570,23 +17699,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; + { + var _rv12 = []; + var lst = yyvstack[yysp]; + + for (var i = 0, len = lst.length; i < len; i++) { + var id = lst[i]; + var m = { + id: id + }; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = { - id: id - }; + if (yyvstack[yysp - 1]) { + m.type = yyvstack[yysp - 1]; + } - if (yyvstack[yysp - 1]) { - m.type = yyvstack[yysp - 1]; + _rv12.push(m); } - rv.push(m); + this.$ = _rv12; } - - this.$ = rv; break; case 62: @@ -17594,13 +17725,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + var _m = yyvstack[yysp]; - if (yyvstack[yysp - 1]) { - m.type = yyvstack[yysp - 1]; - } + if (yyvstack[yysp - 1]) { + _m.type = yyvstack[yysp - 1]; + } - this.$ = [m]; + this.$ = [_m]; + } break; case 63: @@ -17777,32 +17910,38 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - this.$ = [yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '']; + { + this.$ = [yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '']; - if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + if (yyvstack[yysp]) { + var _rv13 = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject118(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + if (_rv13) { + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3(_templateObject118(), _rv13, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } else { + var indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + yyparser.yyError(rmCommonWS$3(_templateObject119(), _rv13, indentedSrc, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } + } + + this.$.push(yyvstack[yysp].action); } - this.$.push(yyvstack[yysp]); - } + if (yyvstack[yysp - 1]) { + if (yyvstack[yysp - 2].length === 0) { + yyparser.yyError(rmCommonWS$3(_templateObject120(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] + /* @handle is very probably NULL! We need this one for some decent location info! */ + ))); + } - if (yyvstack[yysp - 1]) { - if (yyvstack[yysp - 2].length === 0) { - yyparser.yyError(rmCommonWS$3(_templateObject119(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] - /* @handle is very probably NULL! We need this one for some decent location info! */ - ))); + this.$.push(yyvstack[yysp - 1]); } - this.$.push(yyvstack[yysp - 1]); - } - - if (this.$.length === 1) { - this.$ = this.$[0]; + if (this.$.length === 1) { + this.$ = this.$[0]; + } } - break; case 88: @@ -17810,22 +17949,29 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = ['']; + { + this.$ = ['']; - if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + if (yyvstack[yysp]) { + var _rv14 = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject120(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); - } + if (_rv14) { + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3(_templateObject121(), _rv14, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } else { + var _indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); - this.$.push(yyvstack[yysp]); - } + yyparser.yyError(rmCommonWS$3(_templateObject122(), _rv14, _indentedSrc, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } + } - if (this.$.length === 1) { - this.$ = this.$[0]; - } + this.$.push(yyvstack[yysp].action); + } + if (this.$.length === 1) { + this.$ = this.$[0]; + } + } break; case 89: @@ -17835,7 +17981,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 90: @@ -17928,7 +18074,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 105: @@ -17948,11 +18094,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 107: - /*! Production:: prec : %epsilon */ + /*! Production:: prec : %epsilon */ + + case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) @@ -17965,7 +18114,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject126(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + break; + + case 115: + /*! Production:: action : action_ne */ + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; break; case 116: @@ -17973,7 +18133,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + var src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: "\n this.$ = (\n ".concat(src, "\n );\n "), + isArrowAction: true + }; + } break; case 120: @@ -17998,7 +18164,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject127(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 126: @@ -18014,17 +18180,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { - encoding: 'utf-8' - }); - var rv = checkActionBlock$2(fileContent); + { + var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { + encoding: 'utf-8' + }); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject126(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); - } // And no, we don't support nested '%include': + var _rv15 = checkActionBlock$2(fileContent); + + if (_rv15) { + yyparser.yyError(rmCommonWS$3(_templateObject128(), $PATH, _rv15, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } // And no, we don't support nested '%include': - this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -18033,7 +18202,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); + yyparser.yyError(rmCommonWS$3(_templateObject129()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); break; case 131: @@ -18043,7 +18212,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject128()) + yylexer.prettyPrintRange(yylstack[yysp])); + yyparser.yyError(rmCommonWS$3(_templateObject130()) + yylexer.prettyPrintRange(yylstack[yysp])); break; } }, @@ -18224,12 +18393,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (recoveringErrorInfo) { var esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); - v.yyError = true; - v.errorRuleDepth = error_rule_depth; - v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; - recoveringErrorInfo.value_stack[esp] = v; + var _v12 = this.shallowCopyErrorInfo(hash); + + _v12.yyError = true; + _v12.errorRuleDepth = error_rule_depth; + _v12.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; + + recoveringErrorInfo.value_stack[esp] = _v12; recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc); recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1]; ++esp; @@ -18354,8 +18525,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.__error_infos.length = 0; - for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { - var _el2 = this.__error_recovery_infos[_i6]; + for (var _i9 = this.__error_recovery_infos.length - 1; _i9 >= 0; _i9--) { + var _el2 = this.__error_recovery_infos[_i9]; if (_el2 && typeof _el2.destroy === 'function') { _el2.destroy(); @@ -18407,8 +18578,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l2) { if (last_index != null) { - for (var _i7 = i2; _i7 >= i1; _i7--) { - l2 = lstack[_i7]; + for (var _i10 = i2; _i10 >= i1; _i10--) { + l2 = lstack[_i10]; if (l2) { break; @@ -18421,8 +18592,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { - l1 = lstack[_i8]; + for (var _i11 = (i1 || sp) - 1; _i11 >= 0; _i11--) { + l1 = lstack[_i11]; if (l1) { break; @@ -21465,7 +21636,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */ - this.warn(rmCommonWS(_templateObject129(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + this.warn(rmCommonWS(_templateObject131(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); yy_.yytext = [// {NAME} this.matches[1], // optional value/parameters this.matches[2].trim()]; @@ -21586,67 +21757,75 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: action */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 82: /*! Conditions:: action */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 83: /*! Conditions:: action */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 84: /*! Conditions:: option_values */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 85: /*! Conditions:: option_values */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject136()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 86: /*! Conditions:: option_values */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject137()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var _rules4 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject139(), _rules4) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var _rules5 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject140(), _rules5) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ @@ -21654,7 +21833,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: . */ /* b0rk on bad characters */ - yy_.yyerror(rmCommonWS(_templateObject139(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject141(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); return 2; default: @@ -22112,7 +22291,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var ebnf = false; var rmCommonWS$3 = helpers.rmCommonWS; var dquote$2 = helpers.dquote; - var checkActionBlock$2 = helpers.checkActionBlock; // transform ebnf to bnf if necessary + var checkActionBlock$2 = helpers.checkActionBlock; + var trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary function extend(json, grammar) { if (ebnf) { @@ -22504,7 +22684,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.macros; if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject140())); + lex_pre.push(rmCommonWS$4(_templateObject142())); var keylen = 0; for (var key in src) { @@ -22515,11 +22695,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi keylen = (keylen / 4 | 0) * 4 + 4; console.log('macros keylen B:', keylen); - for (var _key in src) { - lex_pre.push(padRight(_key, keylen) + src[_key]); + for (var _key2 in src) { + lex_pre.push(padRight(_key2, keylen) + src[_key2]); } - lex_pre.push(rmCommonWS$4(_templateObject141())); + lex_pre.push(rmCommonWS$4(_templateObject143())); } } { @@ -22527,16 +22707,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.unknownDecls; if (_src && !isEmptyObj(_src)) { - lex_pre.push(rmCommonWS$4(_templateObject142())); + lex_pre.push(rmCommonWS$4(_templateObject144())); for (var i = 0, len = _src.length; i < len; i++) { var entry = _src[i]; - var _key2 = entry.name; + var _key3 = entry.name; var value = entry.value; - lex_pre.push('%' + _key2 + ' ' + value); + lex_pre.push('%' + _key3 + ' ' + value); } - lex_pre.push(rmCommonWS$4(_templateObject143())); + lex_pre.push(rmCommonWS$4(_templateObject145())); } } { @@ -22544,15 +22724,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.options; if (_src2 && !isEmptyObj(_src2)) { - lex_pre.push(rmCommonWS$4(_templateObject144())); + lex_pre.push(rmCommonWS$4(_templateObject146())); - for (var _key3 in _src2) { - var _value = _src2[_key3]; + for (var _key4 in _src2) { + var _value = _src2[_key4]; if (_value) { - lex_pre.push('%options ' + _key3 + '=' + _value); + lex_pre.push('%options ' + _key4 + '=' + _value); } else { - lex_pre.push('%options ' + _key3); + lex_pre.push('%options ' + _key4); } } } @@ -22562,9 +22742,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.startConditions; if (_src3 && !isEmptyObj(_src3)) { - for (var _key4 in _src3) { - var _value2 = _src3[_key4]; - lex_pre.push((_value2 ? '%x ' : '%s ') + _key4); + for (var _key5 in _src3) { + var _value2 = _src3[_key5]; + lex_pre.push((_value2 ? '%x ' : '%s ') + _key5); } } } @@ -22581,9 +22761,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.rules; if (_src5) { - for (var _i9 = 0, _len2 = _src5.length; _i9 < _len2; _i9++) { - var _entry = _src5[_i9]; - var _key5 = _entry[0]; + for (var _i12 = 0, _len8 = _src5.length; _i12 < _len8; _i12++) { + var _entry = _src5[_i12]; + var _key6 = _entry[0]; var action = indentAction(_entry[1], 4); var actionHasLF = /[\r\n]/.test(action); console.log('indented action:', { @@ -22592,16 +22772,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi actionHasLF: actionHasLF }); - if (_key5.length <= 12) { + if (_key6.length <= 12) { if (!actionHasLF) { - lex_rules.push(padRight(_key5, 16) + indentAction(action, 16)); + lex_rules.push(padRight(_key6, 16) + indentAction(action, 16)); } else { - lex_rules.push(padRight(_key5, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(padRight(_key6, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } else if (!actionHasLF) { - lex_rules.push(_key5, makeIndent(16) + indentAction(action, 16)); + lex_rules.push(_key6, makeIndent(16) + indentAction(action, 16)); } else { - lex_rules.push(_key5, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(_key6, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } @@ -22620,15 +22800,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!isEmptyObj(raw.lex)) { // dump the remainder as a comment: var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4(_templateObject145(), rem.replace(/\*\//g, '*\\/')); + out += rmCommonWS$4(_templateObject147(), rem.replace(/\*\//g, '*\\/')); } delete raw.lex; out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject146()) + lex_rules.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject148()) + lex_rules.join('\n') + '\n\n'; if (lex_post.length > 0) { - out += rmCommonWS$4(_templateObject147()) + lex_post.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject149()) + lex_post.join('\n') + '\n\n'; } lex_out_str = out; @@ -22700,69 +22880,69 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var grammarfmt = function grammarfmt(src) { var dst = []; - for (var _key6 in src) { - var prodset = src[_key6]; + for (var _key7 in src) { + var prodset = src[_key7]; var rule = void 0; console.log('format one rule:', { - key: _key6, + key: _key7, prodset: prodset }); if (typeof prodset === 'string') { - rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; - delete src[_key6]; + rule = fmtprod(_key7 + ' : ', [prodset]) + ';'; + delete src[_key7]; } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; - delete src[_key6]; + rule = fmtprod(_key7 + ' : ', [prodset]) + ';'; + delete src[_key7]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(_key6 + ' : ', prodset[0]); + rule = fmtprod(_key7 + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { - delete src[_key6]; + delete src[_key7]; } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(_key6 + '\n : ', [prodset[0]]); + rule = fmtprod(_key7 + '\n : ', [prodset[0]]); delete prodset[0]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(_key6 + '\n : ', prodset[0]); + rule = fmtprod(_key7 + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var _i10 = 1, _len3 = prodset.length; _i10 < _len3; _i10++) { - if (typeof prodset[_i10] === 'string') { - rule += fmtprod('\n | ', [prodset[_i10]]); - delete prodset[_i10]; - } else if (prodset[_i10] instanceof Array) { - rule += fmtprod('\n | ', prodset[_i10]); + for (var _i13 = 1, _len9 = prodset.length; _i13 < _len9; _i13++) { + if (typeof prodset[_i13] === 'string') { + rule += fmtprod('\n | ', [prodset[_i13]]); + delete prodset[_i13]; + } else if (prodset[_i13] instanceof Array) { + rule += fmtprod('\n | ', prodset[_i13]); - if (prodset[_i10].length === 0) { - delete prodset[_i10]; + if (prodset[_i13].length === 0) { + delete prodset[_i13]; } } else { - rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i10]; + rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i13]; } } rule += '\n ;'; if (isEmptyArr(prodset)) { - delete src[_key6]; + delete src[_key7]; } } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -22798,23 +22978,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.unknownDecls; if (_src9 && !isEmptyObj(_src9)) { - lex_pre.push(rmCommonWS$4(_templateObject148())); + lex_pre.push(rmCommonWS$4(_templateObject150())); - for (var _i11 = 0, _len4 = _src9.length; _i11 < _len4; _i11++) { - var _entry2 = _src9[_i11]; - var _key7 = _entry2.name; + for (var _i14 = 0, _len10 = _src9.length; _i14 < _len10; _i14++) { + var _entry2 = _src9[_i14]; + var _key8 = _entry2.name; var _value3 = _entry2.value; - lex_pre.push('%' + _key7 + ' ' + _value3); + lex_pre.push('%' + _key8 + ' ' + _value3); } - lex_pre.push(rmCommonWS$4(_templateObject149())); + lex_pre.push(rmCommonWS$4(_templateObject151())); } } //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { - grammar_pre.push(rmCommonWS$4(_templateObject150(), lex_out_str)); + grammar_pre.push(rmCommonWS$4(_templateObject152(), lex_out_str)); } { @@ -22824,38 +23004,38 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src10 && !isEmptyObj(_src10)) { var a = []; - for (var _key8 in _src10) { - var _value4 = _src10[_key8]; + for (var _key9 in _src10) { + var _value4 = _src10[_key9]; - switch (_key8) { + switch (_key9) { default: if (_value4 !== true) { - a.push('options', '%options ' + _key8 + '=' + _value4); + a.push('options', '%options ' + _key9 + '=' + _value4); } else { - a.push('options', '%options ' + _key8); + a.push('options', '%options ' + _key9); } break; case 'ebnf': if (_value4) { - a.push(_key8, '%ebnf'); + a.push(_key9, '%ebnf'); } break; case 'type': if (_value4) { - a.push(_key8, '%parser-type ' + _value4); + a.push(_key9, '%parser-type ' + _value4); } break; case 'debug': if (typeof _value4 !== 'boolean') { - a.push(_key8, '%debug ' + _value4); + a.push(_key9, '%debug ' + _value4); } else if (_value4) { - a.push(_key8, '%debug'); + a.push(_key9, '%debug'); } break; @@ -22864,9 +23044,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var type = null; - for (var _i12 = 0, _len5 = a.length; _i12 < _len5; _i12 += 2) { - var t = a[_i12]; - var line = a[_i12 + 1]; + for (var _i15 = 0, _len11 = a.length; _i15 < _len11; _i15 += 2) { + var t = a[_i15]; + var line = a[_i15 + 1]; if (t !== type) { type = t; @@ -22885,14 +23065,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src11) { var clean = true; - for (var _i13 = 0, _len6 = _src11.length; _i13 < _len6; _i13++) { - var _entry3 = _src11[_i13]; + for (var _i16 = 0, _len12 = _src11.length; _i16 < _len12; _i16++) { + var _entry3 = _src11[_i16]; grammar_pre.push('%import ' + _entry3.name + ' ' + _entry3.path); delete _entry3.name; delete _entry3.path; if (isEmptyObj(_entry3)) { - delete _src11[_i13]; + delete _src11[_i16]; } else { clean = false; } @@ -22909,14 +23089,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src12) { var _clean = true; - for (var _i14 = 0, _len7 = _src12.length; _i14 < _len7; _i14++) { - var _entry4 = _src12[_i14]; + for (var _i17 = 0, _len13 = _src12.length; _i17 < _len13; _i17++) { + var _entry4 = _src12[_i17]; grammar_pre.push('%code ' + _entry4.qualifier + ' ' + _entry4.include); delete _entry4.qualifier; delete _entry4.include; if (isEmptyObj(_entry4)) { - delete _src12[_i14]; + delete _src12[_i17]; } else { _clean = false; } @@ -22933,8 +23113,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src13) { var _clean2 = true; - for (var _i15 = 0, _len8 = _src13.length; _i15 < _len8; _i15++) { - var _entry5 = _src13[_i15]; + for (var _i18 = 0, _len14 = _src13.length; _i18 < _len14; _i18++) { + var _entry5 = _src13[_i18]; var tokens = _entry5[1]; var _line = '%' + _entry5[0] + ' '; @@ -22946,7 +23126,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi grammar_pre.push(_line); if (_entry5.length === 2) { - delete _src13[_i15]; + delete _src13[_i18]; } else { _clean2 = false; } @@ -22963,8 +23143,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src14) { var _clean3 = true; - for (var _i16 = 0, _len9 = _src14.length; _i16 < _len9; _i16++) { - var _entry6 = _src14[_i16]; + for (var _i19 = 0, _len15 = _src14.length; _i19 < _len15; _i19++) { + var _entry6 = _src14[_i19]; var _line2 = '%token ' + _entry6.id; @@ -22987,7 +23167,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete _entry6.id; if (isEmptyObj(_entry6)) { - delete _src14[_i16]; + delete _src14[_i19]; } else { _clean3 = false; } @@ -23037,14 +23217,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // dump the remainder as a comment: var _rem = JSON5__default['default'].stringify(raw, null, 2); - _out += rmCommonWS$4(_templateObject151(), _rem.replace(/\*\//g, '*\\/')); // delete raw; + _out += rmCommonWS$4(_templateObject153(), _rem.replace(/\*\//g, '*\\/')); // delete raw; } if (!options.showParser) { _out += lex_out_str; } else { _out += grammar_pre.join('\n') + '\n\n'; - _out += rmCommonWS$4(_templateObject152()); + _out += rmCommonWS$4(_templateObject154()); if (grammar_mid.length > 0) { _out += grammar_mid.join('\n') + '\n\n'; @@ -23059,7 +23239,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return '// ' + line; }); - _out += rmCommonWS$4(_templateObject153(), _a2.join('\n')); + _out += rmCommonWS$4(_templateObject155(), _a2.join('\n')); } _out += ebnf_rules.join('\n\n') + '\n\n'; @@ -23068,7 +23248,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (grammar_post.length > 0) { - _out += rmCommonWS$4(_templateObject154()) + grammar_post.join('\n') + '\n\n'; + _out += rmCommonWS$4(_templateObject156()) + grammar_post.join('\n') + '\n\n'; } } @@ -23077,7 +23257,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return '// ' + line; }); - _out = rmCommonWS$4(_templateObject155(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 + _out = rmCommonWS$4(_templateObject157(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 raw = deepClone(originalInput); @@ -23214,8 +23394,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var opts = {}; //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - for (var _len10 = arguments.length, args = new Array(_len10), _key9 = 0; _key9 < _len10; _key9++) { - args[_key9] = arguments[_key9]; + for (var _len16 = arguments.length, args = new Array(_len16), _key10 = 0; _key10 < _len16; _key10++) { + args[_key10] = arguments[_key10]; } if (args[0] !== 'NODEFAULT') { @@ -24109,7 +24289,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi assert__default['default'](p.handle); var rhs = p.handle; - for (var j = 0, _len11 = rhs.length; j < _len11; j++) { + for (var j = 0, _len17 = rhs.length; j < _len17; j++) { var sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); @@ -24354,8 +24534,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (var _i17 = 0; _i17 < rhs.length; _i17++) { - var _sym = rhs[_i17]; + for (var _i20 = 0; _i20 < rhs.length; _i20++) { + var _sym = rhs[_i20]; if (!bnf[_sym] && _sym.length <= maxlen) { addSymbol(_sym); @@ -24607,13 +24787,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (var _i18 = 0; _i18 < rhs.length; _i18++) { - if (rhs[_i18] === 'error') { + for (var _i21 = 0; _i21 < rhs.length; _i21++) { + if (rhs[_i21] === 'error') { hasErrorRecovery = true; } - assert__default['default'](bnf[rhs[_i18]] ? symbols_[rhs[_i18]] : true, 'all nonterminals must already exist in the symbol table'); - assert__default['default'](rhs[_i18] ? symbols_[rhs[_i18]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); + assert__default['default'](bnf[rhs[_i21]] ? symbols_[rhs[_i21]] : true, 'all nonterminals must already exist in the symbol table'); + assert__default['default'](rhs[_i21] ? symbols_[rhs[_i21]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); } } @@ -24627,23 +24807,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var prec_symbols = []; var winning_symbol; - for (var _i19 = r.handle.length - 1; _i19 >= 0; _i19--) { - if (!(r.handle[_i19] in nonterminals) && r.handle[_i19] in operators) { + for (var _i22 = r.handle.length - 1; _i22 >= 0; _i22--) { + if (!(r.handle[_i22] in nonterminals) && r.handle[_i22] in operators) { var old_prec = r.precedence; - var new_prec = operators[r.handle[_i19]].precedence; + var new_prec = operators[r.handle[_i22]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { - prec_symbols.push(r.handle[_i19]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], this.symbol, handle[0]); + prec_symbols.push(r.handle[_i22]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], this.symbol, handle[0]); if (new_prec < old_prec) { - winning_symbol = r.handle[_i19]; + winning_symbol = r.handle[_i22]; } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { - prec_symbols.push(r.handle[_i19]); - winning_symbol = r.handle[_i19]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); + prec_symbols.push(r.handle[_i22]); + winning_symbol = r.handle[_i22]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; @@ -24734,7 +24914,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var dqpos, sqpos, ccmtpos, cppcmtpos; var first = -1; - for (var _c2 = 0;; _c2++) { + for (var _c3 = 0;; _c3++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); // also look for remaining comments which contain quotes of any kind, @@ -25139,7 +25319,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi moduleInit.getInitCodeSection = function getInitCodeSection(section) { var rv = []; - for (var i = 0, _len12 = this.length; i < _len12; i++) { + for (var i = 0, _len18 = this.length; i < _len18; i++) { var m = this[i]; if (m.qualifier === section) { @@ -25157,11 +25337,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { var rv = []; - for (var i = 0, _len13 = this.length; i < _len13; i++) { + for (var i = 0, _len19 = this.length; i < _len19; i++) { var m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { - rv.push(rmCommonWS$5(_templateObject156(), m.qualifier, m.include, m.qualifier)); + rv.push(rmCommonWS$5(_templateObject158(), m.qualifier, m.include, m.qualifier)); this.__consumedInitCodeSlots__[i] = true; } } @@ -25346,13 +25526,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - for (var _i20 = 0; _i20 < rhs.length; _i20++) { + for (var _i23 = 0; _i23 < rhs.length; _i23++) { // check for aliased names, e.g., id[alias] - var _rhs_i = aliased[_i20]; - addName(_rhs_i, _i20); + var _rhs_i = aliased[_i23]; + addName(_rhs_i, _i23); - if (_rhs_i !== rhs[_i20]) { - addName(rhs[_i20], _i20); + if (_rhs_i !== rhs[_i23]) { + addName(rhs[_i23], _i23); } } @@ -25704,6 +25884,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi default_action.push("// END of default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, ")")); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } + default_action.push('\n', action); } @@ -26691,12 +26878,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - out.push(rmCommonWS$5(_templateObject157(), moduleImportsAsCode, moduleNameAsCode.trim())); + out.push(rmCommonWS$5(_templateObject159(), moduleImportsAsCode, moduleNameAsCode.trim())); exportMain = 'main: yyExecMain,'; - invokeMain = rmCommonWS$5(_templateObject158()); + invokeMain = rmCommonWS$5(_templateObject160()); } - out.push(rmCommonWS$5(_templateObject159(), invokeMain, exportMain)); + out.push(rmCommonWS$5(_templateObject161(), invokeMain, exportMain)); var src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; @@ -26710,10 +26897,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - main = rmCommonWS$5(_templateObject160(), moduleImportsAsCode, moduleNameAsCode.trim()); + main = rmCommonWS$5(_templateObject162(), moduleImportsAsCode, moduleNameAsCode.trim()); } - var out = this.generateModule(opt) + rmCommonWS$5(_templateObject161(), moduleName, moduleName, moduleName, moduleName, main); + var out = this.generateModule(opt) + rmCommonWS$5(_templateObject163(), moduleName, moduleName, moduleName, moduleName, main); opt.exportSourceCode.all = out; return out; }; @@ -27103,9 +27290,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var wsi2 = new Array(max_k_len + 1).join(' '); // generate the member assignment list for the `sharedState_yy` object which will store the `parseParams` for everyone to access - for (var _i21 = 0, _len14 = arglist.length; _i21 < _len14; _i21++) { - var _k = arglist[_i21]; - s += '\n' + ws + _k + ': ' + _k + (_i21 < _len14 - 1 ? ',' + wsi2.substr(0, max_k_len - _k.length - 1) : wsi2.substr(0, max_k_len - _k.length)) + ' // parseParams::' + _k; + for (var _i24 = 0, _len20 = arglist.length; _i24 < _len20; _i24++) { + var _k = arglist[_i24]; + s += '\n' + ws + _k + ': ' + _k + (_i24 < _len20 - 1 ? ',' + wsi2.substr(0, max_k_len - _k.length - 1) : wsi2.substr(0, max_k_len - _k.length)) + ' // parseParams::' + _k; } return s; @@ -27289,8 +27476,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi for (var i = 0, len = a.length; i < len; i++) { var k = a[i]; - var v = tbl[k]; - nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys + var _v13 = tbl[k]; + nt[_v13] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -27910,15 +28097,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var line = []; line.push('║'); - for (var _c3 in def_arr) { - var _key10 = clip(_c3, col_width); + for (var _c4 in def_arr) { + var _key11 = clip(_c4, col_width); var delta = clip('∆', col_delta_width); - line.push(_key10); + line.push(_key11); line.push('┊'); line.push(delta); line.push('║'); - track_prev4delta[_c3] = 10000000; + track_prev4delta[_c4] = 10000000; } report.push(line.join('')); @@ -27927,30 +28114,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi line = []; line.push('║'); - for (var _c4 in def_arr) { + for (var _c5 in def_arr) { var val = void 0, delta_val = void 0; - var tbl = def_arr[_c4]; + var tbl = def_arr[_c5]; if (tbl.length > i) { val = tbl[i] || 0; - delta_val = val - track_prev4delta[_c4]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: + delta_val = val - track_prev4delta[_c5]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: if (delta_val < 0) { delta_val = -val - 1; // so that absolute 0 becomes -1, so it can be recognized from delta=0 ('no change') } - track_prev4delta[_c4] = val; + track_prev4delta[_c5] = val; } else { val = '.'; delta_val = '.'; } - var _key11 = clip(val, col_width); + var _key12 = clip(val, col_width); var _delta = clip(delta_val, col_delta_width); - line.push(_key11); + line.push(_key12); line.push('┊'); line.push(_delta); line.push('║'); @@ -28089,18 +28276,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi for (var i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + var _v14 = col[i]; var j = void 0; for (j = i + 1; j < len; j++) { - if (col[j] !== v) { + if (col[j] !== _v14) { break; } } var runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; + var delta = col[i + 1] - _v14; var steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -28148,18 +28335,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { - rv.push(v); + rv.push(_v14); } else if (optimum_gain === gain[0]) { - rv.push('s', '[' + v + ', ' + runlength + ']'); + rv.push('s', '[' + _v14 + ', ' + runlength + ']'); i += runlength - 1; } else if (optimum_gain === gain[1]) { - rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); + rv.push('s', '[' + _v14 + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; } else { - rv.push(v); //assert(0); // should never get here! + rv.push(_v14); //assert(0); // should never get here! } if (optimum_gain > 0) { @@ -28225,7 +28412,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default main method for generated commonjs modules - var commonJsMain = "\nfunction __jison_default_main__(args) {\n // When the parser comes with its own `main` function, then use that one:\n if (typeof exports.parser.main === 'function') {\n return exports.parser.main(args);\n }\n\n if (!args[1]) {\n console.log('Usage:', path.basename(args[0]) + ' FILE');\n process.exit(1);\n }\n const source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n const dst = exports.parser.parse(source);\n console.log('parser output:\\n\\n', {\n type: typeof dst,\n value: dst\n });\n try {\n console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2));\n } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ }\n let rv = 0;\n if (typeof dst === 'number' || typeof dst === 'boolean') {\n rv = dst;\n }\n return dst;\n}\n"; // --- END of commonJsMain chunk --- + var commonJsMain = "\nfunction __jison_default_main__(args) {\n // When the parser comes with its own `main` function, then use that one:\n if (typeof exports.parser.main === 'function') {\n return exports.parser.main(args);\n }\n\n if (!args[1]) {\n console.log('Usage:', path.basename(args[0]) + ' FILE');\n process.exit(1);\n }\n const source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n const dst = exports.parser.parse(source);\n console.log('parser output:\\n\\n', {\n type: typeof dst,\n value: dst\n });\n try {\n console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2));\n } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ }\n let rv = 0;\n if (typeof dst === 'number' || typeof dst === 'boolean') {\n rv = dst;\n }\n return dst;\n}\n"; // --- END of commonJsMain chunk --- var commonJsMainImports = "\nconst fs = require('fs');\nconst path = require('path');\n"; // debug mixin for LR parser generators @@ -28273,7 +28460,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi generatorMixin.createParser = function createParser() { var sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5(_templateObject162(), sourceCodeDef.init, sourceCodeDef.src); + var sourcecode = rmCommonWS$5(_templateObject164(), sourceCodeDef.init, sourceCodeDef.src); var p = code_exec$1(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { //console.log("===============================PARSER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$3(sourcecode); @@ -29049,7 +29236,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return v; }, - help: rmCommonWS$6(_templateObject163(), defaults.defaultActionMode.join(',')) + help: rmCommonWS$6(_templateObject165(), defaults.defaultActionMode.join(',')) }, hasTryCatch: { full: 'try-catch', diff --git a/dist/cli-umd.js b/dist/cli-umd.js index 4213b2e77..b0777773a 100644 --- a/dist/cli-umd.js +++ b/dist/cli-umd.js @@ -2803,20 +2803,21 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2826,6 +2827,7 @@ delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2975,6 +2977,7 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2983,9 +2986,9 @@ break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -3032,6 +3035,7 @@ break; } } + } break; case 9: @@ -3116,8 +3120,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -3125,6 +3130,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -3155,8 +3161,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -3164,6 +3171,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -3194,9 +3202,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3208,6 +3217,7 @@ yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -3233,8 +3243,6 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3255,8 +3263,9 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3271,6 +3280,7 @@ ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3281,11 +3291,13 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3330,10 +3342,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3362,6 +3375,7 @@ type: 'imports', body: body }; + } break; case 24: @@ -3395,10 +3409,11 @@ // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3420,8 +3435,8 @@ `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3437,6 +3452,7 @@ include: srcCode } }; + } break; case 26: @@ -3448,9 +3464,10 @@ // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3464,6 +3481,7 @@ Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3676,9 +3694,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3690,6 +3709,7 @@ yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3713,8 +3733,8 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3725,6 +3745,7 @@ ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3735,13 +3756,14 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3771,6 +3793,7 @@ `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3936,8 +3959,9 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3947,6 +3971,7 @@ `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3957,7 +3982,8 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3975,7 +4001,7 @@ srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3990,6 +4016,7 @@ } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -4235,9 +4262,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4265,6 +4293,7 @@ // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4276,8 +4305,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4292,6 +4322,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4302,6 +4333,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4356,13 +4388,14 @@ } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4650,10 +4683,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4664,8 +4699,10 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4676,6 +4713,7 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4686,7 +4724,7 @@ `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4703,6 +4741,7 @@ } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4798,7 +4837,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4811,6 +4851,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4821,6 +4862,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$2(yyvstack[yysp]); @@ -4829,7 +4871,7 @@ // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4846,6 +4888,7 @@ } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4856,11 +4899,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4874,6 +4918,7 @@ ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4917,9 +4962,10 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4930,6 +4976,7 @@ } } this.$ = srcCode; + } break; case 126: @@ -4981,9 +5028,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4997,6 +5045,7 @@ // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -5007,8 +5056,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -5019,6 +5068,7 @@ ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -5042,10 +5092,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -5074,11 +5125,11 @@ } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -5090,6 +5141,7 @@ } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -10239,21 +10291,22 @@ case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10347,55 +10400,55 @@ case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10403,24 +10456,25 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10448,44 +10502,45 @@ case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10610,38 +10665,39 @@ case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10681,29 +10737,30 @@ case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10807,49 +10864,56 @@ case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10863,7 +10927,8 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11440,9 +11505,9 @@ } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11451,9 +11516,9 @@ // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11461,7 +11526,7 @@ // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11471,11 +11536,11 @@ spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11491,15 +11556,15 @@ // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11559,11 +11624,11 @@ }(); parser.lexer = lexer; - var rmCommonWS$1 = helpers.rmCommonWS; - var checkActionBlock$1 = helpers.checkActionBlock; - var mkIdentifier$2 = helpers.mkIdentifier; - var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; - var trimActionCode$1 = helpers.trimActionCode; + const rmCommonWS$1 = helpers.rmCommonWS; + const checkActionBlock$1 = helpers.checkActionBlock; + const mkIdentifier$2 = helpers.mkIdentifier; + const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; + const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11604,11 +11669,11 @@ // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. - var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; + const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11618,7 +11683,7 @@ function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11627,10 +11692,10 @@ } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11640,7 +11705,7 @@ rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11653,7 +11718,7 @@ // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11675,35 +11740,35 @@ } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11717,19 +11782,19 @@ default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11760,7 +11825,7 @@ // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -13146,6 +13211,12 @@ caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } @@ -20865,8 +20936,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /*! Production:: optional_end_block : %epsilon */ case 101: /*! Production:: suffix : %epsilon */ - case 117: - /*! Production:: action : %epsilon */ case 118: /*! Production:: action_body : %epsilon */ case 133: @@ -20888,7 +20957,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} @@ -20898,6 +20968,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } this.$ = yyvstack[yysp]; + } break; case 6: @@ -20923,8 +20994,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -20934,6 +21006,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } yy.addDeclaration(this.$, { actionInclude: yyvstack[yysp] }); + } break; case 9: @@ -21017,7 +21090,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action code block does not compile: ${rv} @@ -21027,6 +21101,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } this.$ = {include: yyvstack[yysp]}; + } break; case 17: @@ -21037,7 +21112,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -21047,6 +21123,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } this.$ = {include: yyvstack[yysp]}; + } break; case 18: @@ -21173,7 +21250,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} @@ -21188,6 +21266,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; include: yyvstack[yysp] } }; + } break; case 28: @@ -21303,8 +21382,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /*! Production:: action_ne : ACTION */ case 114: /*! Production:: action_ne : include_macro_code */ - case 115: - /*! Production:: action : action_ne */ case 119: /*! Production:: action_body : action_comments_body */ case 123: @@ -21604,17 +21681,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = {id: id}; + { + let rv = []; + let lst = yyvstack[yysp]; + for (let i = 0, len = lst.length; i < len; i++) { + let id = lst[i]; + let m = {id: id}; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } rv.push(m); } this.$ = rv; + } break; case 62: @@ -21625,11 +21704,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + let m = yyvstack[yysp]; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } this.$ = [m]; + } break; case 63: @@ -21907,18 +21988,37 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { this.$ = [(yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '')]; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { @@ -21934,6 +22034,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 88: @@ -21944,22 +22045,42 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = ['']; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - epsilon production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + epsilon production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + epsilon production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 89: @@ -22140,6 +22261,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 107: /*! Production:: prec : %epsilon */ + case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); @@ -22166,6 +22289,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); break; + case 115: + /*! Production:: action : action_ne */ + + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; + break; + case 116: /*! Production:: action : ARROW_ACTION */ @@ -22174,7 +22311,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + let src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: ` + this.$ = ( + ${src} + ); + `, + isArrowAction: true + }; + } break; case 120: @@ -22235,8 +22382,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); - var rv = checkActionBlock$2(fileContent); + { + let fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); + let rv = checkActionBlock$2(fileContent); if (rv) { yyparser.yyError(rmCommonWS$3` included action code file "${$PATH}" does not compile: ${rv} @@ -22247,6 +22395,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And no, we don't support nested '%include': this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -27462,42 +27611,48 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ /*! Rule:: . */ @@ -28031,13 +28186,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; // unescape a string value which is wrapped in quotes/doublequotes function unescQuote(str) { str = '' + str; - var a = str.split('\\\\'); + let a = str.split('\\\\'); a = a.map(function(s) { return s.replace(/\\'/g, '\'').replace(/\\"/g, '"'); @@ -28073,9 +28228,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - var rmCommonWS$3 = helpers.rmCommonWS; - var dquote$2 = helpers.dquote; - var checkActionBlock$2 = helpers.checkActionBlock; + const rmCommonWS$3 = helpers.rmCommonWS; + const dquote$2 = helpers.dquote; + const checkActionBlock$2 = helpers.checkActionBlock; + const trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary @@ -28106,7 +28262,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -31850,6 +32006,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; default_action.push(`// END of default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags})`); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } default_action.push('\n', action); } action = default_action.join('\n'); @@ -35263,9 +35425,9 @@ function __jison_default_main__(args) { try { console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2)); } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ } - let rv = 0; - if (typeof dst === 'number' || typeof dst === 'boolean') { - rv = dst; + let rv = 0; + if (typeof dst === 'number' || typeof dst === 'boolean') { + rv = dst; } return dst; } diff --git a/dist/jison-cjs-es5.js b/dist/jison-cjs-es5.js index bd310db9f..6bbc0047f 100644 --- a/dist/jison-cjs-es5.js +++ b/dist/jison-cjs-es5.js @@ -1,8 +1,28 @@ 'use strict'; -function _templateObject162() { +function _templateObject164() { var data = _taggedTemplateLiteral(["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the `eval()` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "], ["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the \\`eval()\\` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "]); + _templateObject164 = function _templateObject164() { + return data; + }; + + return data; +} + +function _templateObject163() { + var data = _taggedTemplateLiteral(["\n\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.parser = ", ";\n exports.Parser = ", ".Parser;\n exports.parse = function () {\n return ", ".parse.apply(", ", arguments);\n };\n ", "\n }\n "]); + + _templateObject163 = function _templateObject163() { + return data; + }; + + return data; +} + +function _templateObject162() { + var data = _taggedTemplateLiteral(["\n\n ", "\n\n exports.main = ", ";\n\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n exports.main(process.argv.slice(1));\n }\n "]); + _templateObject162 = function _templateObject162() { return data; }; @@ -11,7 +31,7 @@ function _templateObject162() { } function _templateObject161() { - var data = _taggedTemplateLiteral(["\n\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.parser = ", ";\n exports.Parser = ", ".Parser;\n exports.parse = function () {\n return ", ".parse.apply(", ", arguments);\n };\n ", "\n }\n "]); + var data = _taggedTemplateLiteral(["\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser;\n parser.Parser = Parser;\n\n function yyparse() {\n return parser.parse.apply(parser, arguments);\n }\n\n ", "\n\n export default {\n parser,\n Parser,\n parse: yyparse,\n ", "\n };\n "]); _templateObject161 = function _templateObject161() { return data; @@ -21,7 +41,7 @@ function _templateObject161() { } function _templateObject160() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n exports.main = ", ";\n\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n exports.main(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n yyExecMain();\n }\n "]); _templateObject160 = function _templateObject160() { return data; @@ -31,7 +51,7 @@ function _templateObject160() { } function _templateObject159() { - var data = _taggedTemplateLiteral(["\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser;\n parser.Parser = Parser;\n\n function yyparse() {\n return parser.parse.apply(parser, arguments);\n }\n\n ", "\n\n export default {\n parser,\n Parser,\n parse: yyparse,\n ", "\n };\n "]); + var data = _taggedTemplateLiteral(["\n\n ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); _templateObject159 = function _templateObject159() { return data; @@ -41,7 +61,7 @@ function _templateObject159() { } function _templateObject158() { - var data = _taggedTemplateLiteral(["\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n yyExecMain();\n }\n "]); + var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); _templateObject158 = function _templateObject158() { return data; @@ -51,7 +71,7 @@ function _templateObject158() { } function _templateObject157() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // The JISON ", " has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END -----------------------------\n //\n\n "]); _templateObject157 = function _templateObject157() { return data; @@ -61,7 +81,7 @@ function _templateObject157() { } function _templateObject156() { - var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject156 = function _templateObject156() { return data; @@ -71,7 +91,7 @@ function _templateObject156() { } function _templateObject155() { - var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // The JISON ", " has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END -----------------------------\n //\n\n "]); + var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // This is a EBNF grammar. The resulting **BNF** grammar has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END OF BNF grammar --------------\n //\n\n\n "]); _templateObject155 = function _templateObject155() { return data; @@ -81,7 +101,7 @@ function _templateObject155() { } function _templateObject154() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject154 = function _templateObject154() { return data; @@ -91,7 +111,7 @@ function _templateObject154() { } function _templateObject153() { - var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // This is a EBNF grammar. The resulting **BNF** grammar has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END OF BNF grammar --------------\n //\n\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject153 = function _templateObject153() { return data; @@ -101,7 +121,7 @@ function _templateObject153() { } function _templateObject152() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n // ============================== START lexer section =========================== \n \n %lex\n \n ", "\n\n /lex\n\n // ============================== END lexer section =============================\n\n "]); _templateObject152 = function _templateObject152() { return data; @@ -111,7 +131,7 @@ function _templateObject152() { } function _templateObject151() { - var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject151 = function _templateObject151() { return data; @@ -121,7 +141,7 @@ function _templateObject151() { } function _templateObject150() { - var data = _taggedTemplateLiteral(["\n // ============================== START lexer section =========================== \n \n %lex\n \n ", "\n\n /lex\n\n // ============================== END lexer section =============================\n\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject150 = function _templateObject150() { return data; @@ -131,7 +151,7 @@ function _templateObject150() { } function _templateObject149() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject149 = function _templateObject149() { return data; @@ -141,7 +161,7 @@ function _templateObject149() { } function _templateObject148() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject148 = function _templateObject148() { return data; @@ -151,7 +171,7 @@ function _templateObject148() { } function _templateObject147() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject147 = function _templateObject147() { return data; @@ -161,7 +181,7 @@ function _templateObject147() { } function _templateObject146() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n // options:\n "]); _templateObject146 = function _templateObject146() { return data; @@ -171,7 +191,7 @@ function _templateObject146() { } function _templateObject145() { - var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject145 = function _templateObject145() { return data; @@ -181,7 +201,7 @@ function _templateObject145() { } function _templateObject144() { - var data = _taggedTemplateLiteral(["\n // options:\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject144 = function _templateObject144() { return data; @@ -191,7 +211,7 @@ function _templateObject144() { } function _templateObject143() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); _templateObject143 = function _templateObject143() { return data; @@ -201,7 +221,7 @@ function _templateObject143() { } function _templateObject142() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n // macros:\n "]); _templateObject142 = function _templateObject142() { return data; @@ -211,7 +231,7 @@ function _templateObject142() { } function _templateObject141() { - var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); + var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); _templateObject141 = function _templateObject141() { return data; @@ -221,7 +241,7 @@ function _templateObject141() { } function _templateObject140() { - var data = _taggedTemplateLiteral(["\n // macros:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); _templateObject140 = function _templateObject140() { return data; @@ -231,7 +251,7 @@ function _templateObject140() { } function _templateObject139() { - var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); _templateObject139 = function _templateObject139() { return data; @@ -251,7 +271,7 @@ function _templateObject138() { } function _templateObject137() { - var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); _templateObject137 = function _templateObject137() { return data; @@ -261,7 +281,7 @@ function _templateObject137() { } function _templateObject136() { - var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); _templateObject136 = function _templateObject136() { return data; @@ -281,7 +301,7 @@ function _templateObject135() { } function _templateObject134() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); _templateObject134 = function _templateObject134() { return data; @@ -291,7 +311,7 @@ function _templateObject134() { } function _templateObject133() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); _templateObject133 = function _templateObject133() { return data; @@ -311,7 +331,7 @@ function _templateObject132() { } function _templateObject131() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); _templateObject131 = function _templateObject131() { return data; @@ -321,7 +341,7 @@ function _templateObject131() { } function _templateObject130() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); _templateObject130 = function _templateObject130() { return data; @@ -331,7 +351,7 @@ function _templateObject130() { } function _templateObject129() { - var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); _templateObject129 = function _templateObject129() { return data; @@ -341,7 +361,7 @@ function _templateObject129() { } function _templateObject128() { - var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject128 = function _templateObject128() { return data; @@ -351,7 +371,7 @@ function _templateObject128() { } function _templateObject127() { - var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); _templateObject127 = function _templateObject127() { return data; @@ -361,7 +381,7 @@ function _templateObject127() { } function _templateObject126() { - var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); _templateObject126 = function _templateObject126() { return data; @@ -371,7 +391,7 @@ function _templateObject126() { } function _templateObject125() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject125 = function _templateObject125() { return data; @@ -381,7 +401,7 @@ function _templateObject125() { } function _templateObject124() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); _templateObject124 = function _templateObject124() { return data; @@ -391,7 +411,7 @@ function _templateObject124() { } function _templateObject123() { - var data = _taggedTemplateLiteral(["\n %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %epsilon rule action declaration error?\n \n Erroneous area:\n ", "\n "]); _templateObject123 = function _templateObject123() { return data; @@ -401,7 +421,7 @@ function _templateObject123() { } function _templateObject122() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n epsilon production rule arrow action code block does not compile: ", "\n \n Please be aware that the reported compile error MAY be referring\n to the wrapper code which is added by JISON automatically when\n processing arrow actions: the entire action code chunk \n (including wrapper) is:\n \n ", "\n \n Erroneous area:\n ", "\n "]); _templateObject122 = function _templateObject122() { return data; @@ -411,7 +431,7 @@ function _templateObject122() { } function _templateObject121() { - var data = _taggedTemplateLiteral(["\n %epsilon rule action declaration error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n epsilon production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject121 = function _templateObject121() { return data; @@ -421,7 +441,7 @@ function _templateObject121() { } function _templateObject120() { - var data = _taggedTemplateLiteral(["\n epsilon production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n You cannot specify a precedence override for an epsilon (a.k.a. empty) rule!\n \n Erroneous area:\n ", "\n "]); _templateObject120 = function _templateObject120() { return data; @@ -431,7 +451,7 @@ function _templateObject120() { } function _templateObject119() { - var data = _taggedTemplateLiteral(["\n You cannot specify a precedence override for an epsilon (a.k.a. empty) rule!\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n production rule arrow action code block does not compile: ", "\n \n Please be aware that the reported compile error MAY be referring\n to the wrapper code which is added by JISON automatically when\n processing arrow actions: the entire action code chunk \n (including wrapper) is:\n \n ", "\n \n Erroneous area:\n ", "\n "]); _templateObject119 = function _templateObject119() { return data; @@ -441,7 +461,7 @@ function _templateObject119() { } function _templateObject118() { - var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject118 = function _templateObject118() { return data; @@ -4183,30 +4203,32 @@ var parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { - this.$[key] = yyvstack[yysp - 2][key]; - } // if there are any options, add them all, otherwise set options to NULL: - // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: + for (var key in yyvstack[yysp - 2]) { + this.$[key] = yyvstack[yysp - 2][key]; + } // if there are any options, add them all, otherwise set options to NULL: + // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { - this.$.options = yy.options; - break; - } + for (var _key in yy.options) { + this.$.options = yy.options; + break; + } - if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: + if (yy.actionInclude) { + var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: - if (asrc.trim() !== '') { - this.$.actionInclude = asrc; + if (asrc.trim() !== '') { + this.$.actionInclude = asrc; + } } - } - delete yy.options; - delete yy.actionInclude; - return this.$; + delete yy.options; + delete yy.actionInclude; + return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -4310,50 +4332,51 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - if (yyvstack[yysp]) { - switch (yyvstack[yysp].type) { - case 'macro': - this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; - break; + if (yyvstack[yysp]) { + switch (yyvstack[yysp].type) { + case 'macro': + this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; + break; - case 'names': - var condition_defs = yyvstack[yysp].names; + case 'names': + var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + for (var i = 0, len = condition_defs.length; i < len; i++) { + var name = condition_defs[i][0]; - if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { - yyparser.yyError(rmCommonWS$1(_templateObject3(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); - } + if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { + yyparser.yyError(rmCommonWS$1(_templateObject3(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + } - this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' - } // and update the `yy.startConditions` hash table as well, so we have a full set - // by the time this parser arrives at the lexer rules in the input-to-parse: + this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' + } // and update the `yy.startConditions` hash table as well, so we have a full set + // by the time this parser arrives at the lexer rules in the input-to-parse: - yy.startConditions = this.$.startConditions; - break; + yy.startConditions = this.$.startConditions; + break; - case 'unknown': - this.$.unknownDecls.push(yyvstack[yysp].body); - break; + case 'unknown': + this.$.unknownDecls.push(yyvstack[yysp].body); + break; - case 'imports': - this.$.importDecls.push(yyvstack[yysp].body); - break; + case 'imports': + this.$.importDecls.push(yyvstack[yysp].body); + break; - case 'codeSection': - this.$.codeSections.push(yyvstack[yysp].body); - break; + case 'codeSection': + this.$.codeSections.push(yyvstack[yysp].body); + break; - default: - yyparser.yyError(rmCommonWS$1(_templateObject4(), yyvstack[yysp].type, yylexer.prettyPrintRange(yylstack[yysp]))); - break; + default: + yyparser.yyError(rmCommonWS$1(_templateObject4(), yyvstack[yysp].type, yylexer.prettyPrintRange(yylstack[yysp]))); + break; + } } } - break; case 9: @@ -4413,17 +4436,19 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 0; // flag as 'inclusive' - } + for (var _i3 = 0, _len2 = lst.length; _i3 < _len2; _i3++) { + lst[_i3][1] = 0; // flag as 'inclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 13: @@ -4440,17 +4465,19 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var _lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 1; // flag as 'exclusive' - } + for (var _i4 = 0, _len3 = _lst.length; _i4 < _len3; _i4++) { + _lst[_i4][1] = 1; // flag as 'exclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: _lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 15: @@ -4467,19 +4494,21 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + + if (srcCode) { + var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (rv) { + yyparser.yyError(rmCommonWS$1(_templateObject9(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject9(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yy.actionInclude.push(srcCode); } - yy.actionInclude.push(srcCode); + this.$ = null; } - - this.$ = null; break; case 17: @@ -4500,8 +4529,6 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; yyparser.yyError(rmCommonWS$1(_templateObject10(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); this.$ = null; break; @@ -4511,10 +4538,12 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject11(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = null; + { + var start_marker = yyvstack[yysp - 1].trim(); + var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + yyparser.yyError(rmCommonWS$1(_templateObject11(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = null; + } break; case 20: @@ -4522,13 +4551,15 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var _lst2 = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - yy.options[lst[i][0]] = lst[i][1]; - } + for (var _i5 = 0, _len4 = _lst2.length; _i5 < _len4; _i5++) { + yy.options[_lst2[_i5][0]] = _lst2[_i5][1]; + } - this.$ = null; + this.$ = null; + } break; case 21: @@ -4555,28 +4586,30 @@ var parser = { /*! Production:: definition : import_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + { + // check if there are two unvalued options: 'name path' + var _lst3 = yyvstack[yysp - 1]; + var _len5 = _lst3.length; + var body; + + if (_len5 === 2 && _lst3[0][1] === true && _lst3[1][1] === true) { + // `name path`: + body = { + name: _lst3[0][0], + path: _lst3[1][0] + }; + } else if (_len5 <= 2) { + yyparser.yyError(rmCommonWS$1(_templateObject13(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject14(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } - if (len === 2 && lst[0][1] === true && lst[1][1] === true) { - // `name path`: - body = { - name: lst[0][0], - path: lst[1][0] + this.$ = { + type: 'imports', + body: body }; - } else if (len <= 2) { - yyparser.yyError(rmCommonWS$1(_templateObject13(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject14(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); } - - this.$ = { - type: 'imports', - body: body - }; break; case 24: @@ -4592,35 +4625,39 @@ var parser = { /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) - // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + { + // check there's only 1 option which is an identifier + var _lst4 = yyvstack[yysp - 4]; + var _len6 = _lst4.length; - if (len === 1 && lst[0][1] === true) { - // `name`: - name = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1(_templateObject16(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject17(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); - } + var _name; + + if (_len6 === 1 && _lst4[0][1] === true) { + // `name`: + _name = _lst4[0][0]; + } else if (_len6 <= 1) { + yyparser.yyError(rmCommonWS$1(_templateObject16(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject17(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); + } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + var _srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject18(), name, rv, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5]))); - } + var _rv = checkActionBlock$1(_srcCode, yylstack[yysp - 2], yy); - this.$ = { - type: 'codeSection', - body: { - qualifier: name, - include: srcCode + if (_rv) { + yyparser.yyError(rmCommonWS$1(_templateObject18(), _name, _rv, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5]))); } - }; + + this.$ = { + type: 'codeSection', + body: { + qualifier: _name, + include: _srcCode + } + }; + } break; case 26: @@ -4629,10 +4666,15 @@ var parser = { this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - var end_marker_msg = marker_msg.replace(/\{/g, '}'); - yyparser.yyError(rmCommonWS$1(_templateObject19(), marker_msg, end_marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 4]), yyvstack[yysp - 1].errStr)); + { + var _start_marker = yyvstack[yysp - 2].trim(); + + var _marker_msg = _start_marker ? ' or similar, such as ' + _start_marker : ''; + + var end_marker_msg = _marker_msg.replace(/\{/g, '}'); + + yyparser.yyError(rmCommonWS$1(_templateObject19(), _marker_msg, end_marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 4]), yyvstack[yysp - 1].errStr)); + } break; case 27: @@ -4766,19 +4808,21 @@ var parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var _srcCode2 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (_srcCode2) { + var _rv2 = checkActionBlock$1(_srcCode2, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject23(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + if (_rv2) { + yyparser.yyError(rmCommonWS$1(_templateObject23(), _rv2, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + + yy.actionInclude.push(_srcCode2); } - yy.actionInclude.push(srcCode); + this.$ = yyvstack[yysp - 3]; } - - this.$ = yyvstack[yysp - 3]; break; case 42: @@ -4796,10 +4840,12 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject24(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = yyvstack[yysp - 2]; + { + var _start_marker2 = yyvstack[yysp - 1].trim(); + + yyparser.yyError(rmCommonWS$1(_templateObject24(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -4807,20 +4853,24 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error - // is more probably due to indenting the rule regex, rather than an error - // in writing the action code block: + { + var _start_marker3 = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error + // is more probably due to indenting the rule regex, rather than an error + // in writing the action code block: - console.error("*** error! marker:", start_marker); - if (start_marker.indexOf('{') >= 0) { - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject25(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject26(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); - } + console.error("*** error! marker:", _start_marker3); - this.$ = yyvstack[yysp - 2]; + if (_start_marker3.indexOf('{') >= 0) { + var _marker_msg2 = _start_marker3 ? ' or similar, such as ' + _start_marker3 : ''; + + yyparser.yyError(rmCommonWS$1(_templateObject25(), _marker_msg2, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject26(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); + } + + this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -4928,14 +4978,17 @@ var parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + var _srcCode3 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject31(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); - } + var _rv3 = checkActionBlock$1(_srcCode3, yylstack[yysp - 1], yy); - this.$ = [yyvstack[yysp - 3], srcCode]; + if (_rv3) { + yyparser.yyError(rmCommonWS$1(_templateObject31(), _rv3, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); + } + + this.$ = [yyvstack[yysp - 3], _srcCode3]; + } break; case 61: @@ -4943,31 +4996,34 @@ var parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. - // - // Note/Optimization: - // there's no need for braces in the generated expression when we can - // already see the given action is an identifier string or something else - // that's a sure simple thing for a JavaScript `return` statement to carry. - // By doing this, we simplify the token return replacement code replacement - // process which will be applied to the parsed lexer before its code - // will be generated by JISON. - - if (/^[^\r\n;\/]+$/.test(srcCode)) { - srcCode = 'return ' + srcCode; - } else { - srcCode = 'return (' + srcCode + '\n)'; - } + { + var _srcCode4 = trimActionCode$1(yyvstack[yysp - 1]); // 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. + // + // Note/Optimization: + // there's no need for braces in the generated expression when we can + // already see the given action is an identifier string or something else + // that's a sure simple thing for a JavaScript `return` statement to carry. + // By doing this, we simplify the token return replacement code replacement + // process which will be applied to the parsed lexer before its code + // will be generated by JISON. - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject32(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); - } + if (/^[^\r\n;\/]+$/.test(_srcCode4)) { + _srcCode4 = 'return ' + _srcCode4; + } else { + _srcCode4 = 'return (' + _srcCode4 + '\n)'; + } - this.$ = [yyvstack[yysp - 3], srcCode]; + var _rv4 = checkActionBlock$1(_srcCode4, yylstack[yysp - 1], yy); + + if (_rv4) { + yyparser.yyError(rmCommonWS$1(_templateObject32(), _rv4, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); + } + + this.$ = [yyvstack[yysp - 3], _srcCode4]; + } break; case 62: @@ -5087,20 +5143,21 @@ var parser = { /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; // Validate the given condition state: when it isn't known, print an error message - // accordingly: - - if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { - yyparser.yyError(rmCommonWS$1(_templateObject41(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp]))); - } + { + // rewrite + accept star '*' as name + check if we allow empty list? + this.$ = yyvstack[yysp - 2].map(function (el) { + var name = el[0]; // Validate the given condition state: when it isn't known, print an error message + // accordingly: - return name; - }); // '<' '*' '>' - // { $$ = ['*']; } + if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { + yyparser.yyError(rmCommonWS$1(_templateObject41(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp]))); + } + return name; + }); // '<' '*' '>' + // { $$ = ['*']; } + } break; case 74: @@ -5108,78 +5165,82 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { - return el[0]; - }); - yyparser.yyError(rmCommonWS$1(_templateObject42(), lst.join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + { + // rewrite + accept star '*' as name + check if we allow empty list? + var _lst5 = yyvstack[yysp - 1].map(function (el) { + return el[0]; + }); + + yyparser.yyError(rmCommonWS$1(_templateObject42(), _lst5.join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + } break; case 75: /*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // Detect if the regex ends with a pure (Unicode) word; - // we *do* consider escaped characters which are 'alphanumeric' - // to be equivalent to their non-escaped version, hence these are - // all valid 'words' for the 'easy keyword rules' option: - // - // - hello_kitty - // - γεια_σου_γατούλα - // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 - // - // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 - // - // As we only check the *tail*, we also accept these as - // 'easy keywords': - // - // - %options - // - %foo-bar - // - +++a:b:c1 - // - // Note the dash in that last example: there the code will consider - // `bar` to be the keyword, which is fine with us as we're only - // interested in the trailing boundary and patching that one for - // the `easy_keyword_rules` option. - this.$ = yyvstack[yysp]; + { + // Detect if the regex ends with a pure (Unicode) word; + // we *do* consider escaped characters which are 'alphanumeric' + // to be equivalent to their non-escaped version, hence these are + // all valid 'words' for the 'easy keyword rules' option: + // + // - hello_kitty + // - γεια_σου_γατούλα + // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 + // + // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 + // + // As we only check the *tail*, we also accept these as + // 'easy keywords': + // + // - %options + // - %foo-bar + // - +++a:b:c1 + // + // Note the dash in that last example: there the code will consider + // `bar` to be the keyword, which is fine with us as we're only + // interested in the trailing boundary and patching that one for + // the `easy_keyword_rules` option. + this.$ = yyvstack[yysp]; - if (yy.options.easy_keyword_rules) { - // We need to 'protect' `eval` here as keywords are allowed - // to contain double-quotes and other leading cruft. - // `eval` *does* gobble some escapes (such as `\b`) but - // we protect against that through a simple replace regex: - // we're not interested in the special escapes' exact value - // anyway. - // It will also catch escaped escapes (`\\`), which are not - // word characters either, so no need to worry about - // `eval(str)` 'correctly' converting convoluted constructs - // like '\\\\\\\\\\b' in here. - this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); - - try { - // Convert Unicode escapes and other escapes to their literal characters - // BEFORE we go and check whether this item is subject to the - // `easy_keyword_rules` option. - this.$ = JSON.parse('"' + this.$ + '"'); - } catch (ex) { - yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: - - this.$ = '.'; - } // a 'keyword' starts with an alphanumeric character, - // followed by zero or more alphanumerics or digits: - - - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); - - if (XRegExp__default['default'].match(this.$, re)) { - this.$ = yyvstack[yysp] + "\\b"; - } else { - this.$ = yyvstack[yysp]; + if (yy.options.easy_keyword_rules) { + // We need to 'protect' `eval` here as keywords are allowed + // to contain double-quotes and other leading cruft. + // `eval` *does* gobble some escapes (such as `\b`) but + // we protect against that through a simple replace regex: + // we're not interested in the special escapes' exact value + // anyway. + // It will also catch escaped escapes (`\\`), which are not + // word characters either, so no need to worry about + // `eval(str)` 'correctly' converting convoluted constructs + // like '\\\\\\\\\\b' in here. + this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); + + try { + // Convert Unicode escapes and other escapes to their literal characters + // BEFORE we go and check whether this item is subject to the + // `easy_keyword_rules` option. + this.$ = JSON.parse('"' + this.$ + '"'); + } catch (ex) { + yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: + + this.$ = '.'; + } // a 'keyword' starts with an alphanumeric character, + // followed by zero or more alphanumerics or digits: + + + var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + + if (XRegExp__default['default'].match(this.$, re)) { + this.$ = yyvstack[yysp] + "\\b"; + } else { + this.$ = yyvstack[yysp]; + } } } - break; case 76: @@ -5397,10 +5458,14 @@ var parser = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; - this.$ = encodeRegexLiteralStr(s, edge); + { + var src = yyvstack[yysp]; + + var _s = src.substring(1, src.length - 1); + + var edge = src[0]; + this.$ = encodeRegexLiteralStr(_s, edge); + } break; case 112: @@ -5408,30 +5473,34 @@ var parser = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; - this.$ = encodeRegexLiteralStr(s); + { + var _s2 = yyvstack[yysp]; + this.$ = encodeRegexLiteralStr(_s2); + } break; case 113: /*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal behaviour under the given circumstances, i.e. parser context: - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { - yyparser.yyError(rmCommonWS$1(_templateObject45(), yy.__options_category_description__, yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4]))); - } + { + // validate that this is legal behaviour under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { + yyparser.yyError(rmCommonWS$1(_templateObject45(), yy.__options_category_description__, yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4]))); + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { - return opt[0]; - }); - optlist.push(yyvstack[yysp][0]); - yyparser.yyError(rmCommonWS$1(_templateObject46(), yy.__options_category_description__, yyvstack[yysp - 4], optlist.join(' '), yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4]))); - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { + var optlist = yyvstack[yysp - 2].map(function (opt) { + return opt[0]; + }); + optlist.push(yyvstack[yysp][0]); + yyparser.yyError(rmCommonWS$1(_templateObject46(), yy.__options_category_description__, yyvstack[yysp - 4], optlist.join(' '), yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4]))); + } - this.$ = yyvstack[yysp - 2]; - this.$.push(yyvstack[yysp]); + this.$ = yyvstack[yysp - 2]; + this.$.push(yyvstack[yysp]); + } break; case 114: @@ -5493,60 +5562,64 @@ var parser = { this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + var with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1(_templateObject50(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$1(_templateObject50(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]), yyvstack[yysp].errStr)); + } break; case 120: /*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { - this.$ = mkIdentifier$2(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; - // if not, report an error as we don't want confusion due to - // typos and/or garbage input here producing something that - // is usable from a machine perspective. - - if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { + this.$ = mkIdentifier$2(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; + // if not, report an error as we don't want confusion due to + // typos and/or garbage input here producing something that + // is usable from a machine perspective. + + if (!isLegalIdentifierInput$1(yyvstack[yysp])) { + var _with_value_msg = ' (with optional value assignment)'; + + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + _with_value_msg = ''; + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; + yyparser.yyError(rmCommonWS$1(_templateObject51(), _with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } - - yyparser.yyError(rmCommonWS$1(_templateObject51(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } else { + this.$ = yyvstack[yysp]; } - } else { - this.$ = yyvstack[yysp]; } - break; case 121: /*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { - this.$ = yyvstack[yysp]; - } else { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { + this.$ = yyvstack[yysp]; + } else { + var _with_value_msg2 = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + _with_value_msg2 = ''; + } - yyparser.yyError(rmCommonWS$1(_templateObject52(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$1(_templateObject52(), _with_value_msg2, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } } - break; case 122: @@ -5578,17 +5651,19 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + var _srcCode5 = trimActionCode$1(yyvstack[yysp]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + if (_srcCode5) { + var _rv5 = checkActionBlock$1(_srcCode5, yylstack[yysp], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject53(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + if (_rv5) { + yyparser.yyError(rmCommonWS$1(_templateObject53(), _rv5, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } } - } - this.$ = srcCode; + this.$ = _srcCode5; + } break; case 126: @@ -5615,20 +5690,22 @@ var parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var _srcCode6 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (_srcCode6) { + var _rv6 = checkActionBlock$1(_srcCode6, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject56(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); - } - } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) - // we append those protective double newlines right now, as the calling site - // won't do it for us: + if (_rv6) { + yyparser.yyError(rmCommonWS$1(_templateObject56(), _rv6, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) + // we append those protective double newlines right now, as the calling site + // won't do it for us: - this.$ = '\n\n' + srcCode + '\n\n'; + this.$ = '\n\n' + _srcCode6 + '\n\n'; + } break; case 131: @@ -5636,10 +5713,12 @@ var parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject57(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = ''; + { + var _start_marker4 = yyvstack[yysp - 1].trim(); + + yyparser.yyError(rmCommonWS$1(_templateObject57(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = ''; + } break; case 133: @@ -5656,36 +5735,40 @@ var parser = { /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) - // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + { + // check if there is only 1 unvalued options: 'path' + var _lst6 = yyvstack[yysp - 1]; + var _len7 = _lst6.length; + + var _path; - if (len === 1 && lst[0][1] === true) { - // `path`: - path = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1(_templateObject58(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject59(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); - } // **Aside**: And no, we don't support nested '%include'! + if (_len7 === 1 && _lst6[0][1] === true) { + // `path`: + _path = _lst6[0][0]; + } else if (_len7 <= 1) { + yyparser.yyError(rmCommonWS$1(_templateObject58(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject59(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); + } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { - encoding: 'utf-8' - }); - var srcCode = trimActionCode$1(fileContent); + var fileContent = fs__default['default'].readFileSync(_path, { + encoding: 'utf-8' + }); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + var _srcCode7 = trimActionCode$1(fileContent); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject60(), path, rv, yylexer.prettyPrintRange(this._$))); + if (_srcCode7) { + var _rv7 = checkActionBlock$1(_srcCode7, this._$, yy); + + if (_rv7) { + yyparser.yyError(rmCommonWS$1(_templateObject60(), _path, _rv7, yylexer.prettyPrintRange(this._$))); + } } - } - this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + this.$ = '\n// Included by Jison: ' + _path + ':\n\n' + _srcCode7 + '\n\n// End Of Include by Jison: ' + _path + '\n\n'; + } break; case 135: @@ -5875,12 +5958,14 @@ var parser = { if (recoveringErrorInfo) { var esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); - v.yyError = true; - v.errorRuleDepth = error_rule_depth; - v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; - recoveringErrorInfo.value_stack[esp] = v; + var _v = this.shallowCopyErrorInfo(hash); + + _v.yyError = true; + _v.errorRuleDepth = error_rule_depth; + _v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; + + recoveringErrorInfo.value_stack[esp] = _v; recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc); recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1]; ++esp; @@ -6005,8 +6090,8 @@ var parser = { this.__error_infos.length = 0; - for (var _i3 = this.__error_recovery_infos.length - 1; _i3 >= 0; _i3--) { - var _el = this.__error_recovery_infos[_i3]; + for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { + var _el = this.__error_recovery_infos[_i6]; if (_el && typeof _el.destroy === 'function') { _el.destroy(); @@ -6058,8 +6143,8 @@ var parser = { if (!l2) { if (last_index != null) { - for (var _i4 = i2; _i4 >= i1; _i4--) { - l2 = lstack[_i4]; + for (var _i7 = i2; _i7 >= i1; _i7--) { + l2 = lstack[_i7]; if (l2) { break; @@ -6072,8 +6157,8 @@ var parser = { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var _i5 = (i1 || sp) - 1; _i5 >= 0; _i5--) { - l1 = lstack[_i5]; + for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { + l1 = lstack[_i8]; if (l1) { break; @@ -8985,19 +9070,21 @@ var lexer = function () { /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; - var l = scanRegExp(yy_.yytext); + { + yy.include_command_allowed = false; + var l = scanRegExp(yy_.yytext); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); - yy_.yytext = yy_.yytext[0]; - } + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - return 35; + return 35; + } case 10: /*! Conditions:: action */ @@ -9085,65 +9172,67 @@ var lexer = function () { /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - yy.include_command_allowed = false; - this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - - var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + + var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + + var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + var atSOL = !precedingStr + /* @ Start Of File */ + || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + + var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - var prevEnd = 0; - var endMarkerIndex; + var remaining = this.lookAhead(); + var prevEnd = 0; + var endMarkerIndex; - for (;;) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + for (;;) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS(_templateObject65(), endMarker) + this.prettyPrintRange(yy_.yylloc)); - return 24; - } + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS(_templateObject65(), endMarker) + this.prettyPrintRange(yy_.yylloc)); + return 24; + } - break; - } // Allow the start marker to be re-matched by the generated lexer rule regex: + break; + } // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; - } + if (atSOL) { + return 22; + } - return 25; + return 25; + } case 20: /*! Conditions:: rules macro INITIAL */ @@ -9176,41 +9265,43 @@ var lexer = function () { /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); - - this.pushState('action'); // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - - var la = this.lookAhead(); - - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser - } + { + yy.depth = 0; + yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); + + this.pushState('action'); // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + + var la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - return 25; + return 25; + } case 24: /*! Conditions:: rules */ @@ -9367,32 +9458,39 @@ var lexer = function () { /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); - yy_.yytext = v; - } + { + var m = this.matches; + yy_.yytext = NaN; - return 43; + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + var _v2 = parseInt(m[1], 8); + + yy_.yytext = _v2; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + var _v3 = m[2].charCodeAt(0) - 64; + + yy_.yytext = _v3; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + var _v4 = parseInt(m[3], 16); + + yy_.yytext = _v4; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + var _v5 = parseInt(m[4], 16); + + yy_.yytext = _v5; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + var _v6 = parseInt(m[5], 16); + + yy_.yytext = _v6; + } + + return 43; + } case 70: /*! Conditions:: rules macro INITIAL */ @@ -9440,26 +9538,30 @@ var lexer = function () { /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; - yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; - this.pushState('action'); // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': + { + yy.depth = 0; + yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. - this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + var _precedingStr = this.matched[this.matched.length - this.match.length - 1]; - if (atSOL) { - return 22; - } + var _atSOL = !_precedingStr + /* @ Start Of File */ + || _precedingStr === '\n'; - return 25; + this.pushState('action'); // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + + this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + + if (_atSOL) { + return 22; + } + + return 25; + } case 81: /*! Conditions:: INITIAL rules code */ @@ -9550,35 +9652,45 @@ var lexer = function () { /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject73(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS(_templateObject73(), rules) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject74(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var _rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject74(), _rules) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject75(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var _rules2 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject75(), _rules2) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ + { + /* b0rk on bad characters */ + var _rules3 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject76(), rules, dquote(this.topState()), rules) + this.prettyPrintRange(yy_.yylloc)); - return 2; + yy_.yyerror(rmCommonWS(_templateObject76(), _rules3, dquote(this.topState()), _rules3) + this.prettyPrintRange(yy_.yylloc)); + return 2; + } case 104: /*! Conditions:: options */ @@ -10222,28 +10334,28 @@ function encodeRegexLiteralStr(s, edge) { var rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + var _c = s[i]; - switch (c) { + switch (_c) { case '\\': i++; if (i < l) { - c = s[i]; + _c = s[i]; - if (c === edge) { - rv += c; + if (_c === edge) { + rv += _c; continue; } - var pos = '\'"`'.indexOf(c); + var _pos = '\'"`'.indexOf(_c); - if (pos >= 0) { - rv += '\\\\' + c; + if (_pos >= 0) { + rv += '\\\\' + _c; continue; } - if (c === '\\') { + if (_c === '\\') { rv += '\\\\'; continue; } @@ -10278,40 +10390,45 @@ function encodeRegexLiteralStr(s, edge) { if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); - rv += encodeCharCode(v); + var _v7 = parseInt(m[4], 8); + + rv += encodeCharCode(_v7); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; - rv += encodeCharCode(v); + var _v8 = m[5].charCodeAt(0) - 64; + + rv += encodeCharCode(_v8); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); - rv += encodeCharCode(v); + var _v9 = parseInt(m[6], 16); + + rv += encodeCharCode(_v9); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); - rv += encodeCharCode(v); + var _v10 = parseInt(m[7], 16); + + rv += encodeCharCode(_v10); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); - rv += encodeUnicodeCodepoint(v); + var _v11 = parseInt(m[8], 16); + + rv += encodeUnicodeCodepoint(_v11); i += m[8].length; continue; } @@ -10325,21 +10442,21 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + var pos = ".*+?^${}()|[]/\\".indexOf(_c); if (pos >= 0) { - rv += '\\' + c; + rv += '\\' + _c; continue; } - var cc = charCvtTable[c]; + var cc = charCvtTable[_c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = _c.charCodeAt(0); if (cc < 32) { var rvp = codeCvtTable[v]; @@ -10350,7 +10467,7 @@ function encodeRegexLiteralStr(s, edge) { rv += "\\u" + ('0000' + cc.toString(16)).substr(-4); } } else { - rv += c; + rv += _c; } continue; @@ -11782,7 +11899,14 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) simple_rule_count++; caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { - regular_rule_count++; + regular_rule_count++; // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } + routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } @@ -12703,7 +12827,7 @@ function stripUnusedLexerCode(src, opt) { var minl = Math.max(0, line - 10); var b = a.slice(minl, line + 10); - var _c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); + var _c2 = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); var offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2(_templateObject82(), ex, offendingChunk)); @@ -16993,9 +17117,6 @@ var parser$3 = { case 101: /*! Production:: suffix : %epsilon */ - case 117: - /*! Production:: action : %epsilon */ - case 118: /*! Production:: action_body : %epsilon */ @@ -17012,13 +17133,15 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (rv) { + yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = yyvstack[yysp]; + this.$ = yyvstack[yysp]; + } break; case 6: @@ -17040,16 +17163,19 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + this.$ = yyvstack[yysp - 1]; - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject94(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + var _rv8 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - yy.addDeclaration(this.$, { - actionInclude: yyvstack[yysp] - }); + if (_rv8) { + yyparser.yyError(rmCommonWS$3(_templateObject94(), _rv8, yylexer.prettyPrintRange(yylstack[yysp]))); + } + + yy.addDeclaration(this.$, { + actionInclude: yyvstack[yysp] + }); + } break; case 9: @@ -17119,15 +17245,17 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var _rv9 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (_rv9) { + yyparser.yyError(rmCommonWS$3(_templateObject96(), _rv9, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = { - include: yyvstack[yysp] - }; + this.$ = { + include: yyvstack[yysp] + }; + } break; case 17: @@ -17135,15 +17263,17 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var _rv10 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject97(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (_rv10) { + yyparser.yyError(rmCommonWS$3(_templateObject97(), _rv10, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = { - include: yyvstack[yysp] - }; + this.$ = { + include: yyvstack[yysp] + }; + } break; case 18: @@ -17243,18 +17373,20 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); - } + { + var _rv11 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - this.$ = { - initCode: { - qualifier: yyvstack[yysp - 1], - include: yyvstack[yysp] + if (_rv11) { + yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, _rv11, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } - }; + + this.$ = { + initCode: { + qualifier: yyvstack[yysp - 1], + include: yyvstack[yysp] + } + }; + } break; case 28: @@ -17356,9 +17488,6 @@ var parser$3 = { case 114: /*! Production:: action_ne : include_macro_code */ - case 115: - /*! Production:: action : action_ne */ - case 119: /*! Production:: action_body : action_comments_body */ @@ -17568,23 +17697,25 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; + { + var _rv12 = []; + var lst = yyvstack[yysp]; + + for (var i = 0, len = lst.length; i < len; i++) { + var id = lst[i]; + var m = { + id: id + }; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = { - id: id - }; + if (yyvstack[yysp - 1]) { + m.type = yyvstack[yysp - 1]; + } - if (yyvstack[yysp - 1]) { - m.type = yyvstack[yysp - 1]; + _rv12.push(m); } - rv.push(m); + this.$ = _rv12; } - - this.$ = rv; break; case 62: @@ -17592,13 +17723,15 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + var _m = yyvstack[yysp]; - if (yyvstack[yysp - 1]) { - m.type = yyvstack[yysp - 1]; - } + if (yyvstack[yysp - 1]) { + _m.type = yyvstack[yysp - 1]; + } - this.$ = [m]; + this.$ = [_m]; + } break; case 63: @@ -17775,32 +17908,38 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - this.$ = [yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '']; + { + this.$ = [yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '']; - if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + if (yyvstack[yysp]) { + var _rv13 = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject118(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + if (_rv13) { + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3(_templateObject118(), _rv13, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } else { + var indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + yyparser.yyError(rmCommonWS$3(_templateObject119(), _rv13, indentedSrc, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } + } + + this.$.push(yyvstack[yysp].action); } - this.$.push(yyvstack[yysp]); - } + if (yyvstack[yysp - 1]) { + if (yyvstack[yysp - 2].length === 0) { + yyparser.yyError(rmCommonWS$3(_templateObject120(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] + /* @handle is very probably NULL! We need this one for some decent location info! */ + ))); + } - if (yyvstack[yysp - 1]) { - if (yyvstack[yysp - 2].length === 0) { - yyparser.yyError(rmCommonWS$3(_templateObject119(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] - /* @handle is very probably NULL! We need this one for some decent location info! */ - ))); + this.$.push(yyvstack[yysp - 1]); } - this.$.push(yyvstack[yysp - 1]); - } - - if (this.$.length === 1) { - this.$ = this.$[0]; + if (this.$.length === 1) { + this.$ = this.$[0]; + } } - break; case 88: @@ -17808,22 +17947,29 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = ['']; + { + this.$ = ['']; - if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + if (yyvstack[yysp]) { + var _rv14 = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject120(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); - } + if (_rv14) { + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3(_templateObject121(), _rv14, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } else { + var _indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); - this.$.push(yyvstack[yysp]); - } + yyparser.yyError(rmCommonWS$3(_templateObject122(), _rv14, _indentedSrc, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } + } - if (this.$.length === 1) { - this.$ = this.$[0]; - } + this.$.push(yyvstack[yysp].action); + } + if (this.$.length === 1) { + this.$ = this.$[0]; + } + } break; case 89: @@ -17833,7 +17979,7 @@ var parser$3 = { this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 90: @@ -17926,7 +18072,7 @@ var parser$3 = { this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 105: @@ -17946,11 +18092,14 @@ var parser$3 = { this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 107: - /*! Production:: prec : %epsilon */ + /*! Production:: prec : %epsilon */ + + case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) @@ -17963,7 +18112,18 @@ var parser$3 = { this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject126(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + break; + + case 115: + /*! Production:: action : action_ne */ + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; break; case 116: @@ -17971,7 +18131,13 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + var src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: "\n this.$ = (\n ".concat(src, "\n );\n "), + isArrowAction: true + }; + } break; case 120: @@ -17996,7 +18162,7 @@ var parser$3 = { this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject127(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 126: @@ -18012,17 +18178,20 @@ var parser$3 = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { - encoding: 'utf-8' - }); - var rv = checkActionBlock$2(fileContent); + { + var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { + encoding: 'utf-8' + }); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject126(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); - } // And no, we don't support nested '%include': + var _rv15 = checkActionBlock$2(fileContent); + + if (_rv15) { + yyparser.yyError(rmCommonWS$3(_templateObject128(), $PATH, _rv15, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } // And no, we don't support nested '%include': - this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -18031,7 +18200,7 @@ var parser$3 = { this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); + yyparser.yyError(rmCommonWS$3(_templateObject129()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); break; case 131: @@ -18041,7 +18210,7 @@ var parser$3 = { this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject128()) + yylexer.prettyPrintRange(yylstack[yysp])); + yyparser.yyError(rmCommonWS$3(_templateObject130()) + yylexer.prettyPrintRange(yylstack[yysp])); break; } }, @@ -18222,12 +18391,14 @@ var parser$3 = { if (recoveringErrorInfo) { var esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); - v.yyError = true; - v.errorRuleDepth = error_rule_depth; - v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; - recoveringErrorInfo.value_stack[esp] = v; + var _v12 = this.shallowCopyErrorInfo(hash); + + _v12.yyError = true; + _v12.errorRuleDepth = error_rule_depth; + _v12.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; + + recoveringErrorInfo.value_stack[esp] = _v12; recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc); recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1]; ++esp; @@ -18352,8 +18523,8 @@ var parser$3 = { this.__error_infos.length = 0; - for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { - var _el2 = this.__error_recovery_infos[_i6]; + for (var _i9 = this.__error_recovery_infos.length - 1; _i9 >= 0; _i9--) { + var _el2 = this.__error_recovery_infos[_i9]; if (_el2 && typeof _el2.destroy === 'function') { _el2.destroy(); @@ -18405,8 +18576,8 @@ var parser$3 = { if (!l2) { if (last_index != null) { - for (var _i7 = i2; _i7 >= i1; _i7--) { - l2 = lstack[_i7]; + for (var _i10 = i2; _i10 >= i1; _i10--) { + l2 = lstack[_i10]; if (l2) { break; @@ -18419,8 +18590,8 @@ var parser$3 = { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { - l1 = lstack[_i8]; + for (var _i11 = (i1 || sp) - 1; _i11 >= 0; _i11--) { + l1 = lstack[_i11]; if (l1) { break; @@ -21463,7 +21634,7 @@ var lexer$2 = function () { /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */ - this.warn(rmCommonWS(_templateObject129(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + this.warn(rmCommonWS(_templateObject131(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); yy_.yytext = [// {NAME} this.matches[1], // optional value/parameters this.matches[2].trim()]; @@ -21584,67 +21755,75 @@ var lexer$2 = function () { /*! Conditions:: action */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 82: /*! Conditions:: action */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 83: /*! Conditions:: action */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 84: /*! Conditions:: option_values */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 85: /*! Conditions:: option_values */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject136()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 86: /*! Conditions:: option_values */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject137()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var _rules4 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject139(), _rules4) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var _rules5 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject140(), _rules5) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ @@ -21652,7 +21831,7 @@ var lexer$2 = function () { /*! Rule:: . */ /* b0rk on bad characters */ - yy_.yyerror(rmCommonWS(_templateObject139(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject141(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); return 2; default: @@ -22110,7 +22289,8 @@ parser$3.lexer = lexer$2; var ebnf = false; var rmCommonWS$3 = helpers.rmCommonWS; var dquote$2 = helpers.dquote; -var checkActionBlock$2 = helpers.checkActionBlock; // transform ebnf to bnf if necessary +var checkActionBlock$2 = helpers.checkActionBlock; +var trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary function extend(json, grammar) { if (ebnf) { @@ -22502,7 +22682,7 @@ function grammarPrinter(raw, options) { delete raw.lex.macros; if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject140())); + lex_pre.push(rmCommonWS$4(_templateObject142())); var keylen = 0; for (var key in src) { @@ -22513,11 +22693,11 @@ function grammarPrinter(raw, options) { keylen = (keylen / 4 | 0) * 4 + 4; console.log('macros keylen B:', keylen); - for (var _key in src) { - lex_pre.push(padRight(_key, keylen) + src[_key]); + for (var _key2 in src) { + lex_pre.push(padRight(_key2, keylen) + src[_key2]); } - lex_pre.push(rmCommonWS$4(_templateObject141())); + lex_pre.push(rmCommonWS$4(_templateObject143())); } } { @@ -22525,16 +22705,16 @@ function grammarPrinter(raw, options) { delete raw.lex.unknownDecls; if (_src && !isEmptyObj(_src)) { - lex_pre.push(rmCommonWS$4(_templateObject142())); + lex_pre.push(rmCommonWS$4(_templateObject144())); for (var i = 0, len = _src.length; i < len; i++) { var entry = _src[i]; - var _key2 = entry.name; + var _key3 = entry.name; var value = entry.value; - lex_pre.push('%' + _key2 + ' ' + value); + lex_pre.push('%' + _key3 + ' ' + value); } - lex_pre.push(rmCommonWS$4(_templateObject143())); + lex_pre.push(rmCommonWS$4(_templateObject145())); } } { @@ -22542,15 +22722,15 @@ function grammarPrinter(raw, options) { delete raw.lex.options; if (_src2 && !isEmptyObj(_src2)) { - lex_pre.push(rmCommonWS$4(_templateObject144())); + lex_pre.push(rmCommonWS$4(_templateObject146())); - for (var _key3 in _src2) { - var _value = _src2[_key3]; + for (var _key4 in _src2) { + var _value = _src2[_key4]; if (_value) { - lex_pre.push('%options ' + _key3 + '=' + _value); + lex_pre.push('%options ' + _key4 + '=' + _value); } else { - lex_pre.push('%options ' + _key3); + lex_pre.push('%options ' + _key4); } } } @@ -22560,9 +22740,9 @@ function grammarPrinter(raw, options) { delete raw.lex.startConditions; if (_src3 && !isEmptyObj(_src3)) { - for (var _key4 in _src3) { - var _value2 = _src3[_key4]; - lex_pre.push((_value2 ? '%x ' : '%s ') + _key4); + for (var _key5 in _src3) { + var _value2 = _src3[_key5]; + lex_pre.push((_value2 ? '%x ' : '%s ') + _key5); } } } @@ -22579,9 +22759,9 @@ function grammarPrinter(raw, options) { delete raw.lex.rules; if (_src5) { - for (var _i9 = 0, _len2 = _src5.length; _i9 < _len2; _i9++) { - var _entry = _src5[_i9]; - var _key5 = _entry[0]; + for (var _i12 = 0, _len8 = _src5.length; _i12 < _len8; _i12++) { + var _entry = _src5[_i12]; + var _key6 = _entry[0]; var action = indentAction(_entry[1], 4); var actionHasLF = /[\r\n]/.test(action); console.log('indented action:', { @@ -22590,16 +22770,16 @@ function grammarPrinter(raw, options) { actionHasLF: actionHasLF }); - if (_key5.length <= 12) { + if (_key6.length <= 12) { if (!actionHasLF) { - lex_rules.push(padRight(_key5, 16) + indentAction(action, 16)); + lex_rules.push(padRight(_key6, 16) + indentAction(action, 16)); } else { - lex_rules.push(padRight(_key5, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(padRight(_key6, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } else if (!actionHasLF) { - lex_rules.push(_key5, makeIndent(16) + indentAction(action, 16)); + lex_rules.push(_key6, makeIndent(16) + indentAction(action, 16)); } else { - lex_rules.push(_key5, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(_key6, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } @@ -22618,15 +22798,15 @@ function grammarPrinter(raw, options) { if (!isEmptyObj(raw.lex)) { // dump the remainder as a comment: var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4(_templateObject145(), rem.replace(/\*\//g, '*\\/')); + out += rmCommonWS$4(_templateObject147(), rem.replace(/\*\//g, '*\\/')); } delete raw.lex; out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject146()) + lex_rules.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject148()) + lex_rules.join('\n') + '\n\n'; if (lex_post.length > 0) { - out += rmCommonWS$4(_templateObject147()) + lex_post.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject149()) + lex_post.join('\n') + '\n\n'; } lex_out_str = out; @@ -22698,69 +22878,69 @@ function grammarPrinter(raw, options) { var grammarfmt = function grammarfmt(src) { var dst = []; - for (var _key6 in src) { - var prodset = src[_key6]; + for (var _key7 in src) { + var prodset = src[_key7]; var rule = void 0; console.log('format one rule:', { - key: _key6, + key: _key7, prodset: prodset }); if (typeof prodset === 'string') { - rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; - delete src[_key6]; + rule = fmtprod(_key7 + ' : ', [prodset]) + ';'; + delete src[_key7]; } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; - delete src[_key6]; + rule = fmtprod(_key7 + ' : ', [prodset]) + ';'; + delete src[_key7]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(_key6 + ' : ', prodset[0]); + rule = fmtprod(_key7 + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { - delete src[_key6]; + delete src[_key7]; } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(_key6 + '\n : ', [prodset[0]]); + rule = fmtprod(_key7 + '\n : ', [prodset[0]]); delete prodset[0]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(_key6 + '\n : ', prodset[0]); + rule = fmtprod(_key7 + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var _i10 = 1, _len3 = prodset.length; _i10 < _len3; _i10++) { - if (typeof prodset[_i10] === 'string') { - rule += fmtprod('\n | ', [prodset[_i10]]); - delete prodset[_i10]; - } else if (prodset[_i10] instanceof Array) { - rule += fmtprod('\n | ', prodset[_i10]); + for (var _i13 = 1, _len9 = prodset.length; _i13 < _len9; _i13++) { + if (typeof prodset[_i13] === 'string') { + rule += fmtprod('\n | ', [prodset[_i13]]); + delete prodset[_i13]; + } else if (prodset[_i13] instanceof Array) { + rule += fmtprod('\n | ', prodset[_i13]); - if (prodset[_i10].length === 0) { - delete prodset[_i10]; + if (prodset[_i13].length === 0) { + delete prodset[_i13]; } } else { - rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i10]; + rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i13]; } } rule += '\n ;'; if (isEmptyArr(prodset)) { - delete src[_key6]; + delete src[_key7]; } } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -22796,23 +22976,23 @@ function grammarPrinter(raw, options) { delete raw.unknownDecls; if (_src9 && !isEmptyObj(_src9)) { - lex_pre.push(rmCommonWS$4(_templateObject148())); + lex_pre.push(rmCommonWS$4(_templateObject150())); - for (var _i11 = 0, _len4 = _src9.length; _i11 < _len4; _i11++) { - var _entry2 = _src9[_i11]; - var _key7 = _entry2.name; + for (var _i14 = 0, _len10 = _src9.length; _i14 < _len10; _i14++) { + var _entry2 = _src9[_i14]; + var _key8 = _entry2.name; var _value3 = _entry2.value; - lex_pre.push('%' + _key7 + ' ' + _value3); + lex_pre.push('%' + _key8 + ' ' + _value3); } - lex_pre.push(rmCommonWS$4(_templateObject149())); + lex_pre.push(rmCommonWS$4(_templateObject151())); } } //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { - grammar_pre.push(rmCommonWS$4(_templateObject150(), lex_out_str)); + grammar_pre.push(rmCommonWS$4(_templateObject152(), lex_out_str)); } { @@ -22822,38 +23002,38 @@ function grammarPrinter(raw, options) { if (_src10 && !isEmptyObj(_src10)) { var a = []; - for (var _key8 in _src10) { - var _value4 = _src10[_key8]; + for (var _key9 in _src10) { + var _value4 = _src10[_key9]; - switch (_key8) { + switch (_key9) { default: if (_value4 !== true) { - a.push('options', '%options ' + _key8 + '=' + _value4); + a.push('options', '%options ' + _key9 + '=' + _value4); } else { - a.push('options', '%options ' + _key8); + a.push('options', '%options ' + _key9); } break; case 'ebnf': if (_value4) { - a.push(_key8, '%ebnf'); + a.push(_key9, '%ebnf'); } break; case 'type': if (_value4) { - a.push(_key8, '%parser-type ' + _value4); + a.push(_key9, '%parser-type ' + _value4); } break; case 'debug': if (typeof _value4 !== 'boolean') { - a.push(_key8, '%debug ' + _value4); + a.push(_key9, '%debug ' + _value4); } else if (_value4) { - a.push(_key8, '%debug'); + a.push(_key9, '%debug'); } break; @@ -22862,9 +23042,9 @@ function grammarPrinter(raw, options) { var type = null; - for (var _i12 = 0, _len5 = a.length; _i12 < _len5; _i12 += 2) { - var t = a[_i12]; - var line = a[_i12 + 1]; + for (var _i15 = 0, _len11 = a.length; _i15 < _len11; _i15 += 2) { + var t = a[_i15]; + var line = a[_i15 + 1]; if (t !== type) { type = t; @@ -22883,14 +23063,14 @@ function grammarPrinter(raw, options) { if (_src11) { var clean = true; - for (var _i13 = 0, _len6 = _src11.length; _i13 < _len6; _i13++) { - var _entry3 = _src11[_i13]; + for (var _i16 = 0, _len12 = _src11.length; _i16 < _len12; _i16++) { + var _entry3 = _src11[_i16]; grammar_pre.push('%import ' + _entry3.name + ' ' + _entry3.path); delete _entry3.name; delete _entry3.path; if (isEmptyObj(_entry3)) { - delete _src11[_i13]; + delete _src11[_i16]; } else { clean = false; } @@ -22907,14 +23087,14 @@ function grammarPrinter(raw, options) { if (_src12) { var _clean = true; - for (var _i14 = 0, _len7 = _src12.length; _i14 < _len7; _i14++) { - var _entry4 = _src12[_i14]; + for (var _i17 = 0, _len13 = _src12.length; _i17 < _len13; _i17++) { + var _entry4 = _src12[_i17]; grammar_pre.push('%code ' + _entry4.qualifier + ' ' + _entry4.include); delete _entry4.qualifier; delete _entry4.include; if (isEmptyObj(_entry4)) { - delete _src12[_i14]; + delete _src12[_i17]; } else { _clean = false; } @@ -22931,8 +23111,8 @@ function grammarPrinter(raw, options) { if (_src13) { var _clean2 = true; - for (var _i15 = 0, _len8 = _src13.length; _i15 < _len8; _i15++) { - var _entry5 = _src13[_i15]; + for (var _i18 = 0, _len14 = _src13.length; _i18 < _len14; _i18++) { + var _entry5 = _src13[_i18]; var tokens = _entry5[1]; var _line = '%' + _entry5[0] + ' '; @@ -22944,7 +23124,7 @@ function grammarPrinter(raw, options) { grammar_pre.push(_line); if (_entry5.length === 2) { - delete _src13[_i15]; + delete _src13[_i18]; } else { _clean2 = false; } @@ -22961,8 +23141,8 @@ function grammarPrinter(raw, options) { if (_src14) { var _clean3 = true; - for (var _i16 = 0, _len9 = _src14.length; _i16 < _len9; _i16++) { - var _entry6 = _src14[_i16]; + for (var _i19 = 0, _len15 = _src14.length; _i19 < _len15; _i19++) { + var _entry6 = _src14[_i19]; var _line2 = '%token ' + _entry6.id; @@ -22985,7 +23165,7 @@ function grammarPrinter(raw, options) { delete _entry6.id; if (isEmptyObj(_entry6)) { - delete _src14[_i16]; + delete _src14[_i19]; } else { _clean3 = false; } @@ -23035,14 +23215,14 @@ function grammarPrinter(raw, options) { // dump the remainder as a comment: var _rem = JSON5__default['default'].stringify(raw, null, 2); - _out += rmCommonWS$4(_templateObject151(), _rem.replace(/\*\//g, '*\\/')); // delete raw; + _out += rmCommonWS$4(_templateObject153(), _rem.replace(/\*\//g, '*\\/')); // delete raw; } if (!options.showParser) { _out += lex_out_str; } else { _out += grammar_pre.join('\n') + '\n\n'; - _out += rmCommonWS$4(_templateObject152()); + _out += rmCommonWS$4(_templateObject154()); if (grammar_mid.length > 0) { _out += grammar_mid.join('\n') + '\n\n'; @@ -23057,7 +23237,7 @@ function grammarPrinter(raw, options) { return '// ' + line; }); - _out += rmCommonWS$4(_templateObject153(), _a2.join('\n')); + _out += rmCommonWS$4(_templateObject155(), _a2.join('\n')); } _out += ebnf_rules.join('\n\n') + '\n\n'; @@ -23066,7 +23246,7 @@ function grammarPrinter(raw, options) { } if (grammar_post.length > 0) { - _out += rmCommonWS$4(_templateObject154()) + grammar_post.join('\n') + '\n\n'; + _out += rmCommonWS$4(_templateObject156()) + grammar_post.join('\n') + '\n\n'; } } @@ -23075,7 +23255,7 @@ function grammarPrinter(raw, options) { return '// ' + line; }); - _out = rmCommonWS$4(_templateObject155(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 + _out = rmCommonWS$4(_templateObject157(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 raw = deepClone(originalInput); @@ -23212,8 +23392,8 @@ function mkStdOptions$1() { var opts = {}; //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - for (var _len10 = arguments.length, args = new Array(_len10), _key9 = 0; _key9 < _len10; _key9++) { - args[_key9] = arguments[_key9]; + for (var _len16 = arguments.length, args = new Array(_len16), _key10 = 0; _key10 < _len16; _key10++) { + args[_key10] = arguments[_key10]; } if (args[0] !== 'NODEFAULT') { @@ -24107,7 +24287,7 @@ generator.signalUnusedProductions = function () { assert__default['default'](p.handle); var rhs = p.handle; - for (var j = 0, _len11 = rhs.length; j < _len11; j++) { + for (var j = 0, _len17 = rhs.length; j < _len17; j++) { var sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); @@ -24352,8 +24532,8 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (var _i17 = 0; _i17 < rhs.length; _i17++) { - var _sym = rhs[_i17]; + for (var _i20 = 0; _i20 < rhs.length; _i20++) { + var _sym = rhs[_i20]; if (!bnf[_sym] && _sym.length <= maxlen) { addSymbol(_sym); @@ -24605,13 +24785,13 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (var _i18 = 0; _i18 < rhs.length; _i18++) { - if (rhs[_i18] === 'error') { + for (var _i21 = 0; _i21 < rhs.length; _i21++) { + if (rhs[_i21] === 'error') { hasErrorRecovery = true; } - assert__default['default'](bnf[rhs[_i18]] ? symbols_[rhs[_i18]] : true, 'all nonterminals must already exist in the symbol table'); - assert__default['default'](rhs[_i18] ? symbols_[rhs[_i18]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); + assert__default['default'](bnf[rhs[_i21]] ? symbols_[rhs[_i21]] : true, 'all nonterminals must already exist in the symbol table'); + assert__default['default'](rhs[_i21] ? symbols_[rhs[_i21]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); } } @@ -24625,23 +24805,23 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm var prec_symbols = []; var winning_symbol; - for (var _i19 = r.handle.length - 1; _i19 >= 0; _i19--) { - if (!(r.handle[_i19] in nonterminals) && r.handle[_i19] in operators) { + for (var _i22 = r.handle.length - 1; _i22 >= 0; _i22--) { + if (!(r.handle[_i22] in nonterminals) && r.handle[_i22] in operators) { var old_prec = r.precedence; - var new_prec = operators[r.handle[_i19]].precedence; + var new_prec = operators[r.handle[_i22]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { - prec_symbols.push(r.handle[_i19]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], this.symbol, handle[0]); + prec_symbols.push(r.handle[_i22]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], this.symbol, handle[0]); if (new_prec < old_prec) { - winning_symbol = r.handle[_i19]; + winning_symbol = r.handle[_i22]; } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { - prec_symbols.push(r.handle[_i19]); - winning_symbol = r.handle[_i19]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); + prec_symbols.push(r.handle[_i22]); + winning_symbol = r.handle[_i22]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; @@ -24732,7 +24912,7 @@ function preprocessActionCode(s) { var dqpos, sqpos, ccmtpos, cppcmtpos; var first = -1; - for (var _c2 = 0;; _c2++) { + for (var _c3 = 0;; _c3++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); // also look for remaining comments which contain quotes of any kind, @@ -25137,7 +25317,7 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.getInitCodeSection = function getInitCodeSection(section) { var rv = []; - for (var i = 0, _len12 = this.length; i < _len12; i++) { + for (var i = 0, _len18 = this.length; i < _len18; i++) { var m = this[i]; if (m.qualifier === section) { @@ -25155,11 +25335,11 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { var rv = []; - for (var i = 0, _len13 = this.length; i < _len13; i++) { + for (var i = 0, _len19 = this.length; i < _len19; i++) { var m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { - rv.push(rmCommonWS$5(_templateObject156(), m.qualifier, m.include, m.qualifier)); + rv.push(rmCommonWS$5(_templateObject158(), m.qualifier, m.include, m.qualifier)); this.__consumedInitCodeSlots__[i] = true; } } @@ -25344,13 +25524,13 @@ generator.buildProductionActions = function buildProductionActions() { } } - for (var _i20 = 0; _i20 < rhs.length; _i20++) { + for (var _i23 = 0; _i23 < rhs.length; _i23++) { // check for aliased names, e.g., id[alias] - var _rhs_i = aliased[_i20]; - addName(_rhs_i, _i20); + var _rhs_i = aliased[_i23]; + addName(_rhs_i, _i23); - if (_rhs_i !== rhs[_i20]) { - addName(rhs[_i20], _i20); + if (_rhs_i !== rhs[_i23]) { + addName(rhs[_i23], _i23); } } @@ -25702,6 +25882,13 @@ generator.buildProductionActions = function buildProductionActions() { default_action.push("// END of default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, ")")); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } + default_action.push('\n', action); } @@ -26689,12 +26876,12 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - out.push(rmCommonWS$5(_templateObject157(), moduleImportsAsCode, moduleNameAsCode.trim())); + out.push(rmCommonWS$5(_templateObject159(), moduleImportsAsCode, moduleNameAsCode.trim())); exportMain = 'main: yyExecMain,'; - invokeMain = rmCommonWS$5(_templateObject158()); + invokeMain = rmCommonWS$5(_templateObject160()); } - out.push(rmCommonWS$5(_templateObject159(), invokeMain, exportMain)); + out.push(rmCommonWS$5(_templateObject161(), invokeMain, exportMain)); var src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; @@ -26708,10 +26895,10 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - main = rmCommonWS$5(_templateObject160(), moduleImportsAsCode, moduleNameAsCode.trim()); + main = rmCommonWS$5(_templateObject162(), moduleImportsAsCode, moduleNameAsCode.trim()); } - var out = this.generateModule(opt) + rmCommonWS$5(_templateObject161(), moduleName, moduleName, moduleName, moduleName, main); + var out = this.generateModule(opt) + rmCommonWS$5(_templateObject163(), moduleName, moduleName, moduleName, moduleName, main); opt.exportSourceCode.all = out; return out; }; @@ -27101,9 +27288,9 @@ function expandParseArguments(parseFn, self) { var wsi2 = new Array(max_k_len + 1).join(' '); // generate the member assignment list for the `sharedState_yy` object which will store the `parseParams` for everyone to access - for (var _i21 = 0, _len14 = arglist.length; _i21 < _len14; _i21++) { - var _k = arglist[_i21]; - s += '\n' + ws + _k + ': ' + _k + (_i21 < _len14 - 1 ? ',' + wsi2.substr(0, max_k_len - _k.length - 1) : wsi2.substr(0, max_k_len - _k.length)) + ' // parseParams::' + _k; + for (var _i24 = 0, _len20 = arglist.length; _i24 < _len20; _i24++) { + var _k = arglist[_i24]; + s += '\n' + ws + _k + ': ' + _k + (_i24 < _len20 - 1 ? ',' + wsi2.substr(0, max_k_len - _k.length - 1) : wsi2.substr(0, max_k_len - _k.length)) + ' // parseParams::' + _k; } return s; @@ -27287,8 +27474,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { for (var i = 0, len = a.length; i < len; i++) { var k = a[i]; - var v = tbl[k]; - nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys + var _v13 = tbl[k]; + nt[_v13] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -27908,15 +28095,15 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var line = []; line.push('║'); - for (var _c3 in def_arr) { - var _key10 = clip(_c3, col_width); + for (var _c4 in def_arr) { + var _key11 = clip(_c4, col_width); var delta = clip('∆', col_delta_width); - line.push(_key10); + line.push(_key11); line.push('┊'); line.push(delta); line.push('║'); - track_prev4delta[_c3] = 10000000; + track_prev4delta[_c4] = 10000000; } report.push(line.join('')); @@ -27925,30 +28112,30 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio line = []; line.push('║'); - for (var _c4 in def_arr) { + for (var _c5 in def_arr) { var val = void 0, delta_val = void 0; - var tbl = def_arr[_c4]; + var tbl = def_arr[_c5]; if (tbl.length > i) { val = tbl[i] || 0; - delta_val = val - track_prev4delta[_c4]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: + delta_val = val - track_prev4delta[_c5]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: if (delta_val < 0) { delta_val = -val - 1; // so that absolute 0 becomes -1, so it can be recognized from delta=0 ('no change') } - track_prev4delta[_c4] = val; + track_prev4delta[_c5] = val; } else { val = '.'; delta_val = '.'; } - var _key11 = clip(val, col_width); + var _key12 = clip(val, col_width); var _delta = clip(delta_val, col_delta_width); - line.push(_key11); + line.push(_key12); line.push('┊'); line.push(_delta); line.push('║'); @@ -28087,18 +28274,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio for (var i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + var _v14 = col[i]; var j = void 0; for (j = i + 1; j < len; j++) { - if (col[j] !== v) { + if (col[j] !== _v14) { break; } } var runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; + var delta = col[i + 1] - _v14; var steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -28146,18 +28333,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { - rv.push(v); + rv.push(_v14); } else if (optimum_gain === gain[0]) { - rv.push('s', '[' + v + ', ' + runlength + ']'); + rv.push('s', '[' + _v14 + ', ' + runlength + ']'); i += runlength - 1; } else if (optimum_gain === gain[1]) { - rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); + rv.push('s', '[' + _v14 + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; } else { - rv.push(v); //assert(0); // should never get here! + rv.push(_v14); //assert(0); // should never get here! } if (optimum_gain > 0) { @@ -28223,7 +28410,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // default main method for generated commonjs modules -var commonJsMain = "\nfunction __jison_default_main__(args) {\n // When the parser comes with its own `main` function, then use that one:\n if (typeof exports.parser.main === 'function') {\n return exports.parser.main(args);\n }\n\n if (!args[1]) {\n console.log('Usage:', path.basename(args[0]) + ' FILE');\n process.exit(1);\n }\n const source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n const dst = exports.parser.parse(source);\n console.log('parser output:\\n\\n', {\n type: typeof dst,\n value: dst\n });\n try {\n console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2));\n } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ }\n let rv = 0;\n if (typeof dst === 'number' || typeof dst === 'boolean') {\n rv = dst;\n }\n return dst;\n}\n"; // --- END of commonJsMain chunk --- +var commonJsMain = "\nfunction __jison_default_main__(args) {\n // When the parser comes with its own `main` function, then use that one:\n if (typeof exports.parser.main === 'function') {\n return exports.parser.main(args);\n }\n\n if (!args[1]) {\n console.log('Usage:', path.basename(args[0]) + ' FILE');\n process.exit(1);\n }\n const source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n const dst = exports.parser.parse(source);\n console.log('parser output:\\n\\n', {\n type: typeof dst,\n value: dst\n });\n try {\n console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2));\n } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ }\n let rv = 0;\n if (typeof dst === 'number' || typeof dst === 'boolean') {\n rv = dst;\n }\n return dst;\n}\n"; // --- END of commonJsMain chunk --- var commonJsMainImports = "\nconst fs = require('fs');\nconst path = require('path');\n"; // debug mixin for LR parser generators @@ -28271,7 +28458,7 @@ var parser$4 = typal.beget(); generatorMixin.createParser = function createParser() { var sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5(_templateObject162(), sourceCodeDef.init, sourceCodeDef.src); + var sourcecode = rmCommonWS$5(_templateObject164(), sourceCodeDef.init, sourceCodeDef.src); var p = code_exec$1(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { //console.log("===============================PARSER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$3(sourcecode); diff --git a/dist/jison-cjs.js b/dist/jison-cjs.js index e256d09fc..6e6ccbbf7 100644 --- a/dist/jison-cjs.js +++ b/dist/jison-cjs.js @@ -2804,20 +2804,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2827,6 +2828,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2976,6 +2978,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2984,9 +2987,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -3033,6 +3036,7 @@ case 8: break; } } + } break; case 9: @@ -3117,8 +3121,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -3126,6 +3131,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -3156,8 +3162,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -3165,6 +3172,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -3195,9 +3203,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3209,6 +3218,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -3234,8 +3244,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3256,8 +3264,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3272,6 +3281,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3282,11 +3292,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3331,10 +3343,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3363,6 +3376,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3396,10 +3410,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3421,8 +3436,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3438,6 +3453,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3449,9 +3465,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3465,6 +3482,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3677,9 +3695,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3691,6 +3710,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3714,8 +3734,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3726,6 +3746,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3736,13 +3757,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3772,6 +3794,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3937,8 +3960,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3948,6 +3972,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3958,7 +3983,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3976,7 +4002,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3991,6 +4017,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -4236,9 +4263,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4266,6 +4294,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4277,8 +4306,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4293,6 +4323,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4303,6 +4334,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4357,13 +4389,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4651,10 +4684,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4665,8 +4700,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4677,6 +4714,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4687,7 +4725,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4704,6 +4742,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4799,7 +4838,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4812,6 +4852,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4822,6 +4863,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$2(yyvstack[yysp]); @@ -4830,7 +4872,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4847,6 +4889,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4857,11 +4900,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4875,6 +4919,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4918,9 +4963,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4931,6 +4977,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4982,9 +5029,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4998,6 +5046,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -5008,8 +5057,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -5020,6 +5069,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -5043,10 +5093,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -5075,11 +5126,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -5091,6 +5142,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -10240,21 +10292,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10348,55 +10401,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10404,24 +10457,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10449,44 +10503,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10611,38 +10666,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10682,29 +10738,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10808,49 +10865,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10864,7 +10928,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11441,9 +11506,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11452,9 +11517,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11462,7 +11527,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11472,11 +11537,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11492,15 +11557,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11560,11 +11625,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$2 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$2 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11605,11 +11670,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11619,7 +11684,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11628,10 +11693,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11641,7 +11706,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11654,7 +11719,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11676,35 +11741,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11718,19 +11783,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11761,7 +11826,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -13147,6 +13212,12 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } @@ -20866,8 +20937,6 @@ case 4: /*! Production:: optional_end_block : %epsilon */ case 101: /*! Production:: suffix : %epsilon */ -case 117: - /*! Production:: action : %epsilon */ case 118: /*! Production:: action_body : %epsilon */ case 133: @@ -20889,7 +20958,8 @@ case 5: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} @@ -20899,6 +20969,7 @@ case 5: `); } this.$ = yyvstack[yysp]; + } break; case 6: @@ -20924,8 +20995,9 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -20935,6 +21007,7 @@ case 8: `); } yy.addDeclaration(this.$, { actionInclude: yyvstack[yysp] }); + } break; case 9: @@ -21018,7 +21091,8 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action code block does not compile: ${rv} @@ -21028,6 +21102,7 @@ case 16: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 17: @@ -21038,7 +21113,8 @@ case 17: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -21048,6 +21124,7 @@ case 17: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 18: @@ -21174,7 +21251,8 @@ case 27: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} @@ -21189,6 +21267,7 @@ case 27: include: yyvstack[yysp] } }; + } break; case 28: @@ -21304,8 +21383,6 @@ case 113: /*! Production:: action_ne : ACTION */ case 114: /*! Production:: action_ne : include_macro_code */ -case 115: - /*! Production:: action : action_ne */ case 119: /*! Production:: action_body : action_comments_body */ case 123: @@ -21605,17 +21682,19 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = {id: id}; + { + let rv = []; + let lst = yyvstack[yysp]; + for (let i = 0, len = lst.length; i < len; i++) { + let id = lst[i]; + let m = {id: id}; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } rv.push(m); } this.$ = rv; + } break; case 62: @@ -21626,11 +21705,13 @@ case 62: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + let m = yyvstack[yysp]; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } this.$ = [m]; + } break; case 63: @@ -21908,18 +21989,37 @@ case 87: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { this.$ = [(yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '')]; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { @@ -21935,6 +22035,7 @@ case 87: if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 88: @@ -21945,22 +22046,42 @@ case 88: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = ['']; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - epsilon production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + epsilon production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + epsilon production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 89: @@ -22141,6 +22262,8 @@ case 106: case 107: /*! Production:: prec : %epsilon */ +case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); @@ -22167,6 +22290,20 @@ case 112: `); break; +case 115: + /*! Production:: action : action_ne */ + + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; + break; + case 116: /*! Production:: action : ARROW_ACTION */ @@ -22175,7 +22312,17 @@ case 116: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + let src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: ` + this.$ = ( + ${src} + ); + `, + isArrowAction: true + }; + } break; case 120: @@ -22236,8 +22383,9 @@ case 127: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); - var rv = checkActionBlock$2(fileContent); + { + let fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); + let rv = checkActionBlock$2(fileContent); if (rv) { yyparser.yyError(rmCommonWS$3` included action code file "${$PATH}" does not compile: ${rv} @@ -22248,6 +22396,7 @@ case 127: } // And no, we don't support nested '%include': this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -27463,42 +27612,48 @@ var lexer$2 = function() { case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ /*! Rule:: . */ @@ -28032,13 +28187,13 @@ var lexer$2 = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; // unescape a string value which is wrapped in quotes/doublequotes function unescQuote(str) { str = '' + str; - var a = str.split('\\\\'); + let a = str.split('\\\\'); a = a.map(function(s) { return s.replace(/\\'/g, '\'').replace(/\\"/g, '"'); @@ -28074,9 +28229,10 @@ var ebnf = false; -var rmCommonWS$3 = helpers.rmCommonWS; -var dquote$2 = helpers.dquote; -var checkActionBlock$2 = helpers.checkActionBlock; +const rmCommonWS$3 = helpers.rmCommonWS; +const dquote$2 = helpers.dquote; +const checkActionBlock$2 = helpers.checkActionBlock; +const trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary @@ -28107,7 +28263,7 @@ function parseValue$1(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -31851,6 +32007,12 @@ generator.buildProductionActions = function buildProductionActions() { default_action.push(`// END of default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags})`); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } default_action.push('\n', action); } action = default_action.join('\n'); @@ -35264,9 +35426,9 @@ function __jison_default_main__(args) { try { console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2)); } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ } - let rv = 0; - if (typeof dst === 'number' || typeof dst === 'boolean') { - rv = dst; + let rv = 0; + if (typeof dst === 'number' || typeof dst === 'boolean') { + rv = dst; } return dst; } diff --git a/dist/jison-es6.js b/dist/jison-es6.js index cce6d28b8..d5f156ea5 100644 --- a/dist/jison-es6.js +++ b/dist/jison-es6.js @@ -2791,20 +2791,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2814,6 +2815,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2963,6 +2965,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2971,9 +2974,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -3020,6 +3023,7 @@ case 8: break; } } + } break; case 9: @@ -3104,8 +3108,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -3113,6 +3118,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -3143,8 +3149,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -3152,6 +3159,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -3182,9 +3190,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3196,6 +3205,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -3221,8 +3231,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3243,8 +3251,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3259,6 +3268,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3269,11 +3279,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3318,10 +3330,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3350,6 +3363,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3383,10 +3397,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3408,8 +3423,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3425,6 +3440,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3436,9 +3452,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3452,6 +3469,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3664,9 +3682,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3678,6 +3697,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3701,8 +3721,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3713,6 +3733,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3723,13 +3744,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3759,6 +3781,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3924,8 +3947,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3935,6 +3959,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3945,7 +3970,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3963,7 +3989,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3978,6 +4004,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -4223,9 +4250,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4253,6 +4281,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4264,8 +4293,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4280,6 +4310,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4290,6 +4321,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4344,13 +4376,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp('\\w[\\w\\d]*$'); + let re = new XRegExp('\\w[\\w\\d]*$'); if (XRegExp.match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4638,10 +4671,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4652,8 +4687,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4664,6 +4701,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4674,7 +4712,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4691,6 +4729,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4786,7 +4825,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4799,6 +4839,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4809,6 +4850,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$2(yyvstack[yysp]); @@ -4817,7 +4859,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4834,6 +4876,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4844,11 +4887,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4862,6 +4906,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4905,9 +4950,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4918,6 +4964,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4969,9 +5016,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4985,6 +5033,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4995,8 +5044,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -5007,6 +5056,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -5030,10 +5080,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -5062,11 +5113,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -5078,6 +5129,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -10227,21 +10279,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10335,55 +10388,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10391,24 +10444,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10436,44 +10490,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10598,38 +10653,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10669,29 +10725,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10795,49 +10852,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10851,7 +10915,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11428,9 +11493,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11439,9 +11504,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11449,7 +11514,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11459,11 +11524,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11479,15 +11544,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11547,11 +11612,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$2 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$2 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11592,11 +11657,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11606,7 +11671,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11615,10 +11680,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11628,7 +11693,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11641,7 +11706,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11663,35 +11728,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11705,19 +11770,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11748,7 +11813,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -13134,6 +13199,12 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } @@ -20853,8 +20924,6 @@ case 4: /*! Production:: optional_end_block : %epsilon */ case 101: /*! Production:: suffix : %epsilon */ -case 117: - /*! Production:: action : %epsilon */ case 118: /*! Production:: action_body : %epsilon */ case 133: @@ -20876,7 +20945,8 @@ case 5: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} @@ -20886,6 +20956,7 @@ case 5: `); } this.$ = yyvstack[yysp]; + } break; case 6: @@ -20911,8 +20982,9 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -20922,6 +20994,7 @@ case 8: `); } yy.addDeclaration(this.$, { actionInclude: yyvstack[yysp] }); + } break; case 9: @@ -21005,7 +21078,8 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action code block does not compile: ${rv} @@ -21015,6 +21089,7 @@ case 16: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 17: @@ -21025,7 +21100,8 @@ case 17: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -21035,6 +21111,7 @@ case 17: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 18: @@ -21161,7 +21238,8 @@ case 27: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} @@ -21176,6 +21254,7 @@ case 27: include: yyvstack[yysp] } }; + } break; case 28: @@ -21291,8 +21370,6 @@ case 113: /*! Production:: action_ne : ACTION */ case 114: /*! Production:: action_ne : include_macro_code */ -case 115: - /*! Production:: action : action_ne */ case 119: /*! Production:: action_body : action_comments_body */ case 123: @@ -21592,17 +21669,19 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = {id: id}; + { + let rv = []; + let lst = yyvstack[yysp]; + for (let i = 0, len = lst.length; i < len; i++) { + let id = lst[i]; + let m = {id: id}; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } rv.push(m); } this.$ = rv; + } break; case 62: @@ -21613,11 +21692,13 @@ case 62: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + let m = yyvstack[yysp]; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } this.$ = [m]; + } break; case 63: @@ -21895,18 +21976,37 @@ case 87: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { this.$ = [(yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '')]; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { @@ -21922,6 +22022,7 @@ case 87: if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 88: @@ -21932,22 +22033,42 @@ case 88: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = ['']; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - epsilon production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + epsilon production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + epsilon production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 89: @@ -22128,6 +22249,8 @@ case 106: case 107: /*! Production:: prec : %epsilon */ +case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); @@ -22154,6 +22277,20 @@ case 112: `); break; +case 115: + /*! Production:: action : action_ne */ + + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; + break; + case 116: /*! Production:: action : ARROW_ACTION */ @@ -22162,7 +22299,17 @@ case 116: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + let src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: ` + this.$ = ( + ${src} + ); + `, + isArrowAction: true + }; + } break; case 120: @@ -22223,8 +22370,9 @@ case 127: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs.readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); - var rv = checkActionBlock$2(fileContent); + { + let fileContent = fs.readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); + let rv = checkActionBlock$2(fileContent); if (rv) { yyparser.yyError(rmCommonWS$3` included action code file "${$PATH}" does not compile: ${rv} @@ -22235,6 +22383,7 @@ case 127: } // And no, we don't support nested '%include': this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -27450,42 +27599,48 @@ var lexer$2 = function() { case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ /*! Rule:: . */ @@ -28019,13 +28174,13 @@ var lexer$2 = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; // unescape a string value which is wrapped in quotes/doublequotes function unescQuote(str) { str = '' + str; - var a = str.split('\\\\'); + let a = str.split('\\\\'); a = a.map(function(s) { return s.replace(/\\'/g, '\'').replace(/\\"/g, '"'); @@ -28061,9 +28216,10 @@ var ebnf = false; -var rmCommonWS$3 = helpers.rmCommonWS; -var dquote$2 = helpers.dquote; -var checkActionBlock$2 = helpers.checkActionBlock; +const rmCommonWS$3 = helpers.rmCommonWS; +const dquote$2 = helpers.dquote; +const checkActionBlock$2 = helpers.checkActionBlock; +const trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary @@ -28094,7 +28250,7 @@ function parseValue$1(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -31838,6 +31994,12 @@ generator.buildProductionActions = function buildProductionActions() { default_action.push(`// END of default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags})`); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } default_action.push('\n', action); } action = default_action.join('\n'); @@ -35251,9 +35413,9 @@ function __jison_default_main__(args) { try { console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2)); } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ } - let rv = 0; - if (typeof dst === 'number' || typeof dst === 'boolean') { - rv = dst; + let rv = 0; + if (typeof dst === 'number' || typeof dst === 'boolean') { + rv = dst; } return dst; } diff --git a/dist/jison-umd-es5.js b/dist/jison-umd-es5.js index 870008c01..844cd2ea7 100644 --- a/dist/jison-umd-es5.js +++ b/dist/jison-umd-es5.js @@ -1,8 +1,28 @@ "use strict"; -function _templateObject162() { +function _templateObject164() { var data = _taggedTemplateLiteral(["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the `eval()` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "], ["\n ", "\n\n let yy__parser = ", ";\n\n // produce the generated parser function/class as the last value\n // in this chunk of code so that we can be sure to produce *that*\n // one as the 'return value' of the \\`eval()\\` call we'll submit\n // this code to.\n //\n // See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\n\n yy__parser;\n "]); + _templateObject164 = function _templateObject164() { + return data; + }; + + return data; +} + +function _templateObject163() { + var data = _taggedTemplateLiteral(["\n\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.parser = ", ";\n exports.Parser = ", ".Parser;\n exports.parse = function () {\n return ", ".parse.apply(", ", arguments);\n };\n ", "\n }\n "]); + + _templateObject163 = function _templateObject163() { + return data; + }; + + return data; +} + +function _templateObject162() { + var data = _taggedTemplateLiteral(["\n\n ", "\n\n exports.main = ", ";\n\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n exports.main(process.argv.slice(1));\n }\n "]); + _templateObject162 = function _templateObject162() { return data; }; @@ -11,7 +31,7 @@ function _templateObject162() { } function _templateObject161() { - var data = _taggedTemplateLiteral(["\n\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.parser = ", ";\n exports.Parser = ", ".Parser;\n exports.parse = function () {\n return ", ".parse.apply(", ", arguments);\n };\n ", "\n }\n "]); + var data = _taggedTemplateLiteral(["\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser;\n parser.Parser = Parser;\n\n function yyparse() {\n return parser.parse.apply(parser, arguments);\n }\n\n ", "\n\n export default {\n parser,\n Parser,\n parse: yyparse,\n ", "\n };\n "]); _templateObject161 = function _templateObject161() { return data; @@ -21,7 +41,7 @@ function _templateObject161() { } function _templateObject160() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n exports.main = ", ";\n\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n exports.main(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n yyExecMain();\n }\n "]); _templateObject160 = function _templateObject160() { return data; @@ -31,7 +51,7 @@ function _templateObject160() { } function _templateObject159() { - var data = _taggedTemplateLiteral(["\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser;\n parser.Parser = Parser;\n\n function yyparse() {\n return parser.parse.apply(parser, arguments);\n }\n\n ", "\n\n export default {\n parser,\n Parser,\n parse: yyparse,\n ", "\n };\n "]); + var data = _taggedTemplateLiteral(["\n\n ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); _templateObject159 = function _templateObject159() { return data; @@ -41,7 +61,7 @@ function _templateObject159() { } function _templateObject158() { - var data = _taggedTemplateLiteral(["\n // IFF this is the main module executed by NodeJS,\n // then run 'main()' immediately:\n if (typeof module !== 'undefined' && require.main === module) {\n yyExecMain();\n }\n "]); + var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); _templateObject158 = function _templateObject158() { return data; @@ -51,7 +71,7 @@ function _templateObject158() { } function _templateObject157() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // The JISON ", " has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END -----------------------------\n //\n\n "]); _templateObject157 = function _templateObject157() { return data; @@ -61,7 +81,7 @@ function _templateObject157() { } function _templateObject156() { - var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject156 = function _templateObject156() { return data; @@ -71,7 +91,7 @@ function _templateObject156() { } function _templateObject155() { - var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // The JISON ", " has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END -----------------------------\n //\n\n "]); + var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // This is a EBNF grammar. The resulting **BNF** grammar has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END OF BNF grammar --------------\n //\n\n\n "]); _templateObject155 = function _templateObject155() { return data; @@ -81,7 +101,7 @@ function _templateObject155() { } function _templateObject154() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject154 = function _templateObject154() { return data; @@ -91,7 +111,7 @@ function _templateObject154() { } function _templateObject153() { - var data = _taggedTemplateLiteral(["\n //\n // JISON says:\n //\n // This is a EBNF grammar. The resulting **BNF** grammar has been\n // reproduced here for your convenience:\n //\n // ---------------------------- START ---------------------------\n ", "\n // ---------------------------- END OF BNF grammar --------------\n //\n\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject153 = function _templateObject153() { return data; @@ -101,7 +121,7 @@ function _templateObject153() { } function _templateObject152() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n // ============================== START lexer section =========================== \n \n %lex\n \n ", "\n\n /lex\n\n // ============================== END lexer section =============================\n\n "]); _templateObject152 = function _templateObject152() { return data; @@ -111,7 +131,7 @@ function _templateObject152() { } function _templateObject151() { - var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject151 = function _templateObject151() { return data; @@ -121,7 +141,7 @@ function _templateObject151() { } function _templateObject150() { - var data = _taggedTemplateLiteral(["\n // ============================== START lexer section =========================== \n \n %lex\n \n ", "\n\n /lex\n\n // ============================== END lexer section =============================\n\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject150 = function _templateObject150() { return data; @@ -131,7 +151,7 @@ function _templateObject150() { } function _templateObject149() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject149 = function _templateObject149() { return data; @@ -141,7 +161,7 @@ function _templateObject149() { } function _templateObject148() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject148 = function _templateObject148() { return data; @@ -151,7 +171,7 @@ function _templateObject148() { } function _templateObject147() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject147 = function _templateObject147() { return data; @@ -161,7 +181,7 @@ function _templateObject147() { } function _templateObject146() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n // options:\n "]); _templateObject146 = function _templateObject146() { return data; @@ -171,7 +191,7 @@ function _templateObject146() { } function _templateObject145() { - var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject145 = function _templateObject145() { return data; @@ -181,7 +201,7 @@ function _templateObject145() { } function _templateObject144() { - var data = _taggedTemplateLiteral(["\n // options:\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject144 = function _templateObject144() { return data; @@ -191,7 +211,7 @@ function _templateObject144() { } function _templateObject143() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); _templateObject143 = function _templateObject143() { return data; @@ -201,7 +221,7 @@ function _templateObject143() { } function _templateObject142() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n // macros:\n "]); _templateObject142 = function _templateObject142() { return data; @@ -211,7 +231,7 @@ function _templateObject142() { } function _templateObject141() { - var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); + var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); _templateObject141 = function _templateObject141() { return data; @@ -221,7 +241,7 @@ function _templateObject141() { } function _templateObject140() { - var data = _taggedTemplateLiteral(["\n // macros:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); _templateObject140 = function _templateObject140() { return data; @@ -231,7 +251,7 @@ function _templateObject140() { } function _templateObject139() { - var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); _templateObject139 = function _templateObject139() { return data; @@ -251,7 +271,7 @@ function _templateObject138() { } function _templateObject137() { - var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); _templateObject137 = function _templateObject137() { return data; @@ -261,7 +281,7 @@ function _templateObject137() { } function _templateObject136() { - var data = _taggedTemplateLiteral(["\n unterminated string constant encountered while lexing\n ", ".\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); _templateObject136 = function _templateObject136() { return data; @@ -281,7 +301,7 @@ function _templateObject135() { } function _templateObject134() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); _templateObject134 = function _templateObject134() { return data; @@ -291,7 +311,7 @@ function _templateObject134() { } function _templateObject133() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in %options entry.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); _templateObject133 = function _templateObject133() { return data; @@ -311,7 +331,7 @@ function _templateObject132() { } function _templateObject131() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); _templateObject131 = function _templateObject131() { return data; @@ -321,7 +341,7 @@ function _templateObject131() { } function _templateObject130() { - var data = _taggedTemplateLiteral(["\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); _templateObject130 = function _templateObject130() { return data; @@ -331,7 +351,7 @@ function _templateObject130() { } function _templateObject129() { - var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); _templateObject129 = function _templateObject129() { return data; @@ -341,7 +361,7 @@ function _templateObject129() { } function _templateObject128() { - var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject128 = function _templateObject128() { return data; @@ -351,7 +371,7 @@ function _templateObject128() { } function _templateObject127() { - var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); _templateObject127 = function _templateObject127() { return data; @@ -361,7 +381,7 @@ function _templateObject127() { } function _templateObject126() { - var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); _templateObject126 = function _templateObject126() { return data; @@ -371,7 +391,7 @@ function _templateObject126() { } function _templateObject125() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject125 = function _templateObject125() { return data; @@ -381,7 +401,7 @@ function _templateObject125() { } function _templateObject124() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); _templateObject124 = function _templateObject124() { return data; @@ -391,7 +411,7 @@ function _templateObject124() { } function _templateObject123() { - var data = _taggedTemplateLiteral(["\n %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %epsilon rule action declaration error?\n \n Erroneous area:\n ", "\n "]); _templateObject123 = function _templateObject123() { return data; @@ -401,7 +421,7 @@ function _templateObject123() { } function _templateObject122() { - var data = _taggedTemplateLiteral(["\n Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n epsilon production rule arrow action code block does not compile: ", "\n \n Please be aware that the reported compile error MAY be referring\n to the wrapper code which is added by JISON automatically when\n processing arrow actions: the entire action code chunk \n (including wrapper) is:\n \n ", "\n \n Erroneous area:\n ", "\n "]); _templateObject122 = function _templateObject122() { return data; @@ -411,7 +431,7 @@ function _templateObject122() { } function _templateObject121() { - var data = _taggedTemplateLiteral(["\n %epsilon rule action declaration error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n epsilon production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject121 = function _templateObject121() { return data; @@ -421,7 +441,7 @@ function _templateObject121() { } function _templateObject120() { - var data = _taggedTemplateLiteral(["\n epsilon production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n You cannot specify a precedence override for an epsilon (a.k.a. empty) rule!\n \n Erroneous area:\n ", "\n "]); _templateObject120 = function _templateObject120() { return data; @@ -431,7 +451,7 @@ function _templateObject120() { } function _templateObject119() { - var data = _taggedTemplateLiteral(["\n You cannot specify a precedence override for an epsilon (a.k.a. empty) rule!\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n production rule arrow action code block does not compile: ", "\n \n Please be aware that the reported compile error MAY be referring\n to the wrapper code which is added by JISON automatically when\n processing arrow actions: the entire action code chunk \n (including wrapper) is:\n \n ", "\n \n Erroneous area:\n ", "\n "]); _templateObject119 = function _templateObject119() { return data; @@ -441,7 +461,7 @@ function _templateObject119() { } function _templateObject118() { - var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject118 = function _templateObject118() { return data; @@ -4170,30 +4190,32 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { - this.$[key] = yyvstack[yysp - 2][key]; - } // if there are any options, add them all, otherwise set options to NULL: - // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: + for (var key in yyvstack[yysp - 2]) { + this.$[key] = yyvstack[yysp - 2][key]; + } // if there are any options, add them all, otherwise set options to NULL: + // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { - this.$.options = yy.options; - break; - } + for (var _key in yy.options) { + this.$.options = yy.options; + break; + } - if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: + if (yy.actionInclude) { + var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: - if (asrc.trim() !== '') { - this.$.actionInclude = asrc; + if (asrc.trim() !== '') { + this.$.actionInclude = asrc; + } } - } - delete yy.options; - delete yy.actionInclude; - return this.$; + delete yy.options; + delete yy.actionInclude; + return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -4297,50 +4319,51 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - if (yyvstack[yysp]) { - switch (yyvstack[yysp].type) { - case 'macro': - this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; - break; + if (yyvstack[yysp]) { + switch (yyvstack[yysp].type) { + case 'macro': + this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; + break; - case 'names': - var condition_defs = yyvstack[yysp].names; + case 'names': + var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + for (var i = 0, len = condition_defs.length; i < len; i++) { + var name = condition_defs[i][0]; - if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { - yyparser.yyError(rmCommonWS$1(_templateObject3(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); - } + if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { + yyparser.yyError(rmCommonWS$1(_templateObject3(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + } - this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' - } // and update the `yy.startConditions` hash table as well, so we have a full set - // by the time this parser arrives at the lexer rules in the input-to-parse: + this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' + } // and update the `yy.startConditions` hash table as well, so we have a full set + // by the time this parser arrives at the lexer rules in the input-to-parse: - yy.startConditions = this.$.startConditions; - break; + yy.startConditions = this.$.startConditions; + break; - case 'unknown': - this.$.unknownDecls.push(yyvstack[yysp].body); - break; + case 'unknown': + this.$.unknownDecls.push(yyvstack[yysp].body); + break; - case 'imports': - this.$.importDecls.push(yyvstack[yysp].body); - break; + case 'imports': + this.$.importDecls.push(yyvstack[yysp].body); + break; - case 'codeSection': - this.$.codeSections.push(yyvstack[yysp].body); - break; + case 'codeSection': + this.$.codeSections.push(yyvstack[yysp].body); + break; - default: - yyparser.yyError(rmCommonWS$1(_templateObject4(), yyvstack[yysp].type, yylexer.prettyPrintRange(yylstack[yysp]))); - break; + default: + yyparser.yyError(rmCommonWS$1(_templateObject4(), yyvstack[yysp].type, yylexer.prettyPrintRange(yylstack[yysp]))); + break; + } } } - break; case 9: @@ -4400,17 +4423,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 0; // flag as 'inclusive' - } + for (var _i3 = 0, _len2 = lst.length; _i3 < _len2; _i3++) { + lst[_i3][1] = 0; // flag as 'inclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 13: @@ -4427,17 +4452,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var _lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 1; // flag as 'exclusive' - } + for (var _i4 = 0, _len3 = _lst.length; _i4 < _len3; _i4++) { + _lst[_i4][1] = 1; // flag as 'exclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: _lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 15: @@ -4454,19 +4481,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + + if (srcCode) { + var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (rv) { + yyparser.yyError(rmCommonWS$1(_templateObject9(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject9(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yy.actionInclude.push(srcCode); } - yy.actionInclude.push(srcCode); + this.$ = null; } - - this.$ = null; break; case 17: @@ -4487,8 +4516,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; yyparser.yyError(rmCommonWS$1(_templateObject10(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); this.$ = null; break; @@ -4498,10 +4525,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject11(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = null; + { + var start_marker = yyvstack[yysp - 1].trim(); + var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + yyparser.yyError(rmCommonWS$1(_templateObject11(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = null; + } break; case 20: @@ -4509,13 +4538,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + var _lst2 = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - yy.options[lst[i][0]] = lst[i][1]; - } + for (var _i5 = 0, _len4 = _lst2.length; _i5 < _len4; _i5++) { + yy.options[_lst2[_i5][0]] = _lst2[_i5][1]; + } - this.$ = null; + this.$ = null; + } break; case 21: @@ -4542,28 +4573,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Production:: definition : import_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + { + // check if there are two unvalued options: 'name path' + var _lst3 = yyvstack[yysp - 1]; + var _len5 = _lst3.length; + var body; + + if (_len5 === 2 && _lst3[0][1] === true && _lst3[1][1] === true) { + // `name path`: + body = { + name: _lst3[0][0], + path: _lst3[1][0] + }; + } else if (_len5 <= 2) { + yyparser.yyError(rmCommonWS$1(_templateObject13(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject14(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } - if (len === 2 && lst[0][1] === true && lst[1][1] === true) { - // `name path`: - body = { - name: lst[0][0], - path: lst[1][0] + this.$ = { + type: 'imports', + body: body }; - } else if (len <= 2) { - yyparser.yyError(rmCommonWS$1(_templateObject13(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject14(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); } - - this.$ = { - type: 'imports', - body: body - }; break; case 24: @@ -4579,35 +4612,39 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) - // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + { + // check there's only 1 option which is an identifier + var _lst4 = yyvstack[yysp - 4]; + var _len6 = _lst4.length; - if (len === 1 && lst[0][1] === true) { - // `name`: - name = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1(_templateObject16(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject17(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); - } + var _name; + + if (_len6 === 1 && _lst4[0][1] === true) { + // `name`: + _name = _lst4[0][0]; + } else if (_len6 <= 1) { + yyparser.yyError(rmCommonWS$1(_templateObject16(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject17(), yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5]))); + } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + var _srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject18(), name, rv, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5]))); - } + var _rv = checkActionBlock$1(_srcCode, yylstack[yysp - 2], yy); - this.$ = { - type: 'codeSection', - body: { - qualifier: name, - include: srcCode + if (_rv) { + yyparser.yyError(rmCommonWS$1(_templateObject18(), _name, _rv, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5]))); } - }; + + this.$ = { + type: 'codeSection', + body: { + qualifier: _name, + include: _srcCode + } + }; + } break; case 26: @@ -4616,10 +4653,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - var end_marker_msg = marker_msg.replace(/\{/g, '}'); - yyparser.yyError(rmCommonWS$1(_templateObject19(), marker_msg, end_marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 4]), yyvstack[yysp - 1].errStr)); + { + var _start_marker = yyvstack[yysp - 2].trim(); + + var _marker_msg = _start_marker ? ' or similar, such as ' + _start_marker : ''; + + var end_marker_msg = _marker_msg.replace(/\{/g, '}'); + + yyparser.yyError(rmCommonWS$1(_templateObject19(), _marker_msg, end_marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 4]), yyvstack[yysp - 1].errStr)); + } break; case 27: @@ -4753,19 +4795,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var _srcCode2 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (_srcCode2) { + var _rv2 = checkActionBlock$1(_srcCode2, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject23(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + if (_rv2) { + yyparser.yyError(rmCommonWS$1(_templateObject23(), _rv2, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + + yy.actionInclude.push(_srcCode2); } - yy.actionInclude.push(srcCode); + this.$ = yyvstack[yysp - 3]; } - - this.$ = yyvstack[yysp - 3]; break; case 42: @@ -4783,10 +4827,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject24(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = yyvstack[yysp - 2]; + { + var _start_marker2 = yyvstack[yysp - 1].trim(); + + yyparser.yyError(rmCommonWS$1(_templateObject24(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -4794,20 +4840,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error - // is more probably due to indenting the rule regex, rather than an error - // in writing the action code block: + { + var _start_marker3 = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error + // is more probably due to indenting the rule regex, rather than an error + // in writing the action code block: - console.error("*** error! marker:", start_marker); - if (start_marker.indexOf('{') >= 0) { - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject25(), marker_msg, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject26(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); - } + console.error("*** error! marker:", _start_marker3); - this.$ = yyvstack[yysp - 2]; + if (_start_marker3.indexOf('{') >= 0) { + var _marker_msg2 = _start_marker3 ? ' or similar, such as ' + _start_marker3 : ''; + + yyparser.yyError(rmCommonWS$1(_templateObject25(), _marker_msg2, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject26(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); + } + + this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -4915,14 +4965,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + var _srcCode3 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject31(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); - } + var _rv3 = checkActionBlock$1(_srcCode3, yylstack[yysp - 1], yy); - this.$ = [yyvstack[yysp - 3], srcCode]; + if (_rv3) { + yyparser.yyError(rmCommonWS$1(_templateObject31(), _rv3, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); + } + + this.$ = [yyvstack[yysp - 3], _srcCode3]; + } break; case 61: @@ -4930,31 +4983,34 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. - // - // Note/Optimization: - // there's no need for braces in the generated expression when we can - // already see the given action is an identifier string or something else - // that's a sure simple thing for a JavaScript `return` statement to carry. - // By doing this, we simplify the token return replacement code replacement - // process which will be applied to the parsed lexer before its code - // will be generated by JISON. - - if (/^[^\r\n;\/]+$/.test(srcCode)) { - srcCode = 'return ' + srcCode; - } else { - srcCode = 'return (' + srcCode + '\n)'; - } + { + var _srcCode4 = trimActionCode$1(yyvstack[yysp - 1]); // 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. + // + // Note/Optimization: + // there's no need for braces in the generated expression when we can + // already see the given action is an identifier string or something else + // that's a sure simple thing for a JavaScript `return` statement to carry. + // By doing this, we simplify the token return replacement code replacement + // process which will be applied to the parsed lexer before its code + // will be generated by JISON. - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject32(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); - } + if (/^[^\r\n;\/]+$/.test(_srcCode4)) { + _srcCode4 = 'return ' + _srcCode4; + } else { + _srcCode4 = 'return (' + _srcCode4 + '\n)'; + } - this.$ = [yyvstack[yysp - 3], srcCode]; + var _rv4 = checkActionBlock$1(_srcCode4, yylstack[yysp - 1], yy); + + if (_rv4) { + yyparser.yyError(rmCommonWS$1(_templateObject32(), _rv4, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3]))); + } + + this.$ = [yyvstack[yysp - 3], _srcCode4]; + } break; case 62: @@ -5074,20 +5130,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; // Validate the given condition state: when it isn't known, print an error message - // accordingly: - - if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { - yyparser.yyError(rmCommonWS$1(_templateObject41(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp]))); - } + { + // rewrite + accept star '*' as name + check if we allow empty list? + this.$ = yyvstack[yysp - 2].map(function (el) { + var name = el[0]; // Validate the given condition state: when it isn't known, print an error message + // accordingly: - return name; - }); // '<' '*' '>' - // { $$ = ['*']; } + if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { + yyparser.yyError(rmCommonWS$1(_templateObject41(), name, name, name, yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp]))); + } + return name; + }); // '<' '*' '>' + // { $$ = ['*']; } + } break; case 74: @@ -5095,78 +5152,82 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { - return el[0]; - }); - yyparser.yyError(rmCommonWS$1(_templateObject42(), lst.join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + { + // rewrite + accept star '*' as name + check if we allow empty list? + var _lst5 = yyvstack[yysp - 1].map(function (el) { + return el[0]; + }); + + yyparser.yyError(rmCommonWS$1(_templateObject42(), _lst5.join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + } break; case 75: /*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // Detect if the regex ends with a pure (Unicode) word; - // we *do* consider escaped characters which are 'alphanumeric' - // to be equivalent to their non-escaped version, hence these are - // all valid 'words' for the 'easy keyword rules' option: - // - // - hello_kitty - // - γεια_σου_γατούλα - // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 - // - // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 - // - // As we only check the *tail*, we also accept these as - // 'easy keywords': - // - // - %options - // - %foo-bar - // - +++a:b:c1 - // - // Note the dash in that last example: there the code will consider - // `bar` to be the keyword, which is fine with us as we're only - // interested in the trailing boundary and patching that one for - // the `easy_keyword_rules` option. - this.$ = yyvstack[yysp]; + { + // Detect if the regex ends with a pure (Unicode) word; + // we *do* consider escaped characters which are 'alphanumeric' + // to be equivalent to their non-escaped version, hence these are + // all valid 'words' for the 'easy keyword rules' option: + // + // - hello_kitty + // - γεια_σου_γατούλα + // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 + // + // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 + // + // As we only check the *tail*, we also accept these as + // 'easy keywords': + // + // - %options + // - %foo-bar + // - +++a:b:c1 + // + // Note the dash in that last example: there the code will consider + // `bar` to be the keyword, which is fine with us as we're only + // interested in the trailing boundary and patching that one for + // the `easy_keyword_rules` option. + this.$ = yyvstack[yysp]; - if (yy.options.easy_keyword_rules) { - // We need to 'protect' `eval` here as keywords are allowed - // to contain double-quotes and other leading cruft. - // `eval` *does* gobble some escapes (such as `\b`) but - // we protect against that through a simple replace regex: - // we're not interested in the special escapes' exact value - // anyway. - // It will also catch escaped escapes (`\\`), which are not - // word characters either, so no need to worry about - // `eval(str)` 'correctly' converting convoluted constructs - // like '\\\\\\\\\\b' in here. - this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); - - try { - // Convert Unicode escapes and other escapes to their literal characters - // BEFORE we go and check whether this item is subject to the - // `easy_keyword_rules` option. - this.$ = JSON.parse('"' + this.$ + '"'); - } catch (ex) { - yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: - - this.$ = '.'; - } // a 'keyword' starts with an alphanumeric character, - // followed by zero or more alphanumerics or digits: - - - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); - - if (XRegExp__default['default'].match(this.$, re)) { - this.$ = yyvstack[yysp] + "\\b"; - } else { - this.$ = yyvstack[yysp]; + if (yy.options.easy_keyword_rules) { + // We need to 'protect' `eval` here as keywords are allowed + // to contain double-quotes and other leading cruft. + // `eval` *does* gobble some escapes (such as `\b`) but + // we protect against that through a simple replace regex: + // we're not interested in the special escapes' exact value + // anyway. + // It will also catch escaped escapes (`\\`), which are not + // word characters either, so no need to worry about + // `eval(str)` 'correctly' converting convoluted constructs + // like '\\\\\\\\\\b' in here. + this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); + + try { + // Convert Unicode escapes and other escapes to their literal characters + // BEFORE we go and check whether this item is subject to the + // `easy_keyword_rules` option. + this.$ = JSON.parse('"' + this.$ + '"'); + } catch (ex) { + yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: + + this.$ = '.'; + } // a 'keyword' starts with an alphanumeric character, + // followed by zero or more alphanumerics or digits: + + + var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + + if (XRegExp__default['default'].match(this.$, re)) { + this.$ = yyvstack[yysp] + "\\b"; + } else { + this.$ = yyvstack[yysp]; + } } } - break; case 76: @@ -5384,10 +5445,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; - this.$ = encodeRegexLiteralStr(s, edge); + { + var src = yyvstack[yysp]; + + var _s = src.substring(1, src.length - 1); + + var edge = src[0]; + this.$ = encodeRegexLiteralStr(_s, edge); + } break; case 112: @@ -5395,30 +5460,34 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; - this.$ = encodeRegexLiteralStr(s); + { + var _s2 = yyvstack[yysp]; + this.$ = encodeRegexLiteralStr(_s2); + } break; case 113: /*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal behaviour under the given circumstances, i.e. parser context: - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { - yyparser.yyError(rmCommonWS$1(_templateObject45(), yy.__options_category_description__, yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4]))); - } + { + // validate that this is legal behaviour under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { + yyparser.yyError(rmCommonWS$1(_templateObject45(), yy.__options_category_description__, yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4]))); + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { - return opt[0]; - }); - optlist.push(yyvstack[yysp][0]); - yyparser.yyError(rmCommonWS$1(_templateObject46(), yy.__options_category_description__, yyvstack[yysp - 4], optlist.join(' '), yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4]))); - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { + var optlist = yyvstack[yysp - 2].map(function (opt) { + return opt[0]; + }); + optlist.push(yyvstack[yysp][0]); + yyparser.yyError(rmCommonWS$1(_templateObject46(), yy.__options_category_description__, yyvstack[yysp - 4], optlist.join(' '), yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4]))); + } - this.$ = yyvstack[yysp - 2]; - this.$.push(yyvstack[yysp]); + this.$ = yyvstack[yysp - 2]; + this.$.push(yyvstack[yysp]); + } break; case 114: @@ -5480,60 +5549,64 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + var with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1(_templateObject50(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$1(_templateObject50(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]), yyvstack[yysp].errStr)); + } break; case 120: /*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { - this.$ = mkIdentifier$2(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; - // if not, report an error as we don't want confusion due to - // typos and/or garbage input here producing something that - // is usable from a machine perspective. - - if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { + this.$ = mkIdentifier$2(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; + // if not, report an error as we don't want confusion due to + // typos and/or garbage input here producing something that + // is usable from a machine perspective. + + if (!isLegalIdentifierInput$1(yyvstack[yysp])) { + var _with_value_msg = ' (with optional value assignment)'; + + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + _with_value_msg = ''; + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; + yyparser.yyError(rmCommonWS$1(_templateObject51(), _with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } - - yyparser.yyError(rmCommonWS$1(_templateObject51(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } else { + this.$ = yyvstack[yysp]; } - } else { - this.$ = yyvstack[yysp]; } - break; case 121: /*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { - this.$ = yyvstack[yysp]; - } else { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { + this.$ = yyvstack[yysp]; + } else { + var _with_value_msg2 = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + _with_value_msg2 = ''; + } - yyparser.yyError(rmCommonWS$1(_templateObject52(), with_value_msg, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$1(_templateObject52(), _with_value_msg2, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } } - break; case 122: @@ -5565,17 +5638,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + var _srcCode5 = trimActionCode$1(yyvstack[yysp]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + if (_srcCode5) { + var _rv5 = checkActionBlock$1(_srcCode5, yylstack[yysp], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject53(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + if (_rv5) { + yyparser.yyError(rmCommonWS$1(_templateObject53(), _rv5, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } } - } - this.$ = srcCode; + this.$ = _srcCode5; + } break; case 126: @@ -5602,20 +5677,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + var _srcCode6 = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (_srcCode6) { + var _rv6 = checkActionBlock$1(_srcCode6, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject56(), rv, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); - } - } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) - // we append those protective double newlines right now, as the calling site - // won't do it for us: + if (_rv6) { + yyparser.yyError(rmCommonWS$1(_templateObject56(), _rv6, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + } + } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) + // we append those protective double newlines right now, as the calling site + // won't do it for us: - this.$ = '\n\n' + srcCode + '\n\n'; + this.$ = '\n\n' + _srcCode6 + '\n\n'; + } break; case 131: @@ -5623,10 +5700,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1(_templateObject57(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); - this.$ = ''; + { + var _start_marker4 = yyvstack[yysp - 1].trim(); + + yyparser.yyError(rmCommonWS$1(_templateObject57(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp].errStr)); + this.$ = ''; + } break; case 133: @@ -5643,36 +5722,40 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) - // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + { + // check if there is only 1 unvalued options: 'path' + var _lst6 = yyvstack[yysp - 1]; + var _len7 = _lst6.length; + + var _path; - if (len === 1 && lst[0][1] === true) { - // `path`: - path = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1(_templateObject58(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); - } else { - yyparser.yyError(rmCommonWS$1(_templateObject59(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); - } // **Aside**: And no, we don't support nested '%include'! + if (_len7 === 1 && _lst6[0][1] === true) { + // `path`: + _path = _lst6[0][0]; + } else if (_len7 <= 1) { + yyparser.yyError(rmCommonWS$1(_templateObject58(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); + } else { + yyparser.yyError(rmCommonWS$1(_templateObject59(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), $error.errStr)); + } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { - encoding: 'utf-8' - }); - var srcCode = trimActionCode$1(fileContent); + var fileContent = fs__default['default'].readFileSync(_path, { + encoding: 'utf-8' + }); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + var _srcCode7 = trimActionCode$1(fileContent); - if (rv) { - yyparser.yyError(rmCommonWS$1(_templateObject60(), path, rv, yylexer.prettyPrintRange(this._$))); + if (_srcCode7) { + var _rv7 = checkActionBlock$1(_srcCode7, this._$, yy); + + if (_rv7) { + yyparser.yyError(rmCommonWS$1(_templateObject60(), _path, _rv7, yylexer.prettyPrintRange(this._$))); + } } - } - this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + this.$ = '\n// Included by Jison: ' + _path + ':\n\n' + _srcCode7 + '\n\n// End Of Include by Jison: ' + _path + '\n\n'; + } break; case 135: @@ -5862,12 +5945,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (recoveringErrorInfo) { var esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); - v.yyError = true; - v.errorRuleDepth = error_rule_depth; - v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; - recoveringErrorInfo.value_stack[esp] = v; + var _v = this.shallowCopyErrorInfo(hash); + + _v.yyError = true; + _v.errorRuleDepth = error_rule_depth; + _v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; + + recoveringErrorInfo.value_stack[esp] = _v; recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc); recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1]; ++esp; @@ -5992,8 +6077,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.__error_infos.length = 0; - for (var _i3 = this.__error_recovery_infos.length - 1; _i3 >= 0; _i3--) { - var _el = this.__error_recovery_infos[_i3]; + for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { + var _el = this.__error_recovery_infos[_i6]; if (_el && typeof _el.destroy === 'function') { _el.destroy(); @@ -6045,8 +6130,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l2) { if (last_index != null) { - for (var _i4 = i2; _i4 >= i1; _i4--) { - l2 = lstack[_i4]; + for (var _i7 = i2; _i7 >= i1; _i7--) { + l2 = lstack[_i7]; if (l2) { break; @@ -6059,8 +6144,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var _i5 = (i1 || sp) - 1; _i5 >= 0; _i5--) { - l1 = lstack[_i5]; + for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { + l1 = lstack[_i8]; if (l1) { break; @@ -8972,19 +9057,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; - var l = scanRegExp(yy_.yytext); + { + yy.include_command_allowed = false; + var l = scanRegExp(yy_.yytext); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); - yy_.yytext = yy_.yytext[0]; - } + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - return 35; + return 35; + } case 10: /*! Conditions:: action */ @@ -9072,65 +9159,67 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - yy.include_command_allowed = false; - this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - - var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + + var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + + var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + var atSOL = !precedingStr + /* @ Start Of File */ + || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + + var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - var prevEnd = 0; - var endMarkerIndex; + var remaining = this.lookAhead(); + var prevEnd = 0; + var endMarkerIndex; - for (;;) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + for (;;) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS(_templateObject65(), endMarker) + this.prettyPrintRange(yy_.yylloc)); - return 24; - } + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS(_templateObject65(), endMarker) + this.prettyPrintRange(yy_.yylloc)); + return 24; + } - break; - } // Allow the start marker to be re-matched by the generated lexer rule regex: + break; + } // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; - } + if (atSOL) { + return 22; + } - return 25; + return 25; + } case 20: /*! Conditions:: rules macro INITIAL */ @@ -9163,41 +9252,43 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); - - this.pushState('action'); // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - - var la = this.lookAhead(); - - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser - } + { + yy.depth = 0; + yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); + + this.pushState('action'); // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + + var la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - return 25; + return 25; + } case 24: /*! Conditions:: rules */ @@ -9354,32 +9445,39 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); - yy_.yytext = v; - } + { + var m = this.matches; + yy_.yytext = NaN; - return 43; + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + var _v2 = parseInt(m[1], 8); + + yy_.yytext = _v2; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + var _v3 = m[2].charCodeAt(0) - 64; + + yy_.yytext = _v3; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + var _v4 = parseInt(m[3], 16); + + yy_.yytext = _v4; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + var _v5 = parseInt(m[4], 16); + + yy_.yytext = _v5; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + var _v6 = parseInt(m[5], 16); + + yy_.yytext = _v6; + } + + return 43; + } case 70: /*! Conditions:: rules macro INITIAL */ @@ -9427,26 +9525,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; - yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; - this.pushState('action'); // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': + { + yy.depth = 0; + yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. - this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + var _precedingStr = this.matched[this.matched.length - this.match.length - 1]; - if (atSOL) { - return 22; - } + var _atSOL = !_precedingStr + /* @ Start Of File */ + || _precedingStr === '\n'; - return 25; + this.pushState('action'); // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + + this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + + if (_atSOL) { + return 22; + } + + return 25; + } case 81: /*! Conditions:: INITIAL rules code */ @@ -9537,35 +9639,45 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject73(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS(_templateObject73(), rules) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject74(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var _rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject74(), _rules) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject75(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 39; + { + var _rules2 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject75(), _rules2) + this.prettyPrintRange(yy_.yylloc)); + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ + { + /* b0rk on bad characters */ + var _rules3 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject76(), rules, dquote(this.topState()), rules) + this.prettyPrintRange(yy_.yylloc)); - return 2; + yy_.yyerror(rmCommonWS(_templateObject76(), _rules3, dquote(this.topState()), _rules3) + this.prettyPrintRange(yy_.yylloc)); + return 2; + } case 104: /*! Conditions:: options */ @@ -10209,28 +10321,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + var _c = s[i]; - switch (c) { + switch (_c) { case '\\': i++; if (i < l) { - c = s[i]; + _c = s[i]; - if (c === edge) { - rv += c; + if (_c === edge) { + rv += _c; continue; } - var pos = '\'"`'.indexOf(c); + var _pos = '\'"`'.indexOf(_c); - if (pos >= 0) { - rv += '\\\\' + c; + if (_pos >= 0) { + rv += '\\\\' + _c; continue; } - if (c === '\\') { + if (_c === '\\') { rv += '\\\\'; continue; } @@ -10265,40 +10377,45 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); - rv += encodeCharCode(v); + var _v7 = parseInt(m[4], 8); + + rv += encodeCharCode(_v7); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; - rv += encodeCharCode(v); + var _v8 = m[5].charCodeAt(0) - 64; + + rv += encodeCharCode(_v8); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); - rv += encodeCharCode(v); + var _v9 = parseInt(m[6], 16); + + rv += encodeCharCode(_v9); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); - rv += encodeCharCode(v); + var _v10 = parseInt(m[7], 16); + + rv += encodeCharCode(_v10); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); - rv += encodeUnicodeCodepoint(v); + var _v11 = parseInt(m[8], 16); + + rv += encodeUnicodeCodepoint(_v11); i += m[8].length; continue; } @@ -10312,21 +10429,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + var pos = ".*+?^${}()|[]/\\".indexOf(_c); if (pos >= 0) { - rv += '\\' + c; + rv += '\\' + _c; continue; } - var cc = charCvtTable[c]; + var cc = charCvtTable[_c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = _c.charCodeAt(0); if (cc < 32) { var rvp = codeCvtTable[v]; @@ -10337,7 +10454,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi rv += "\\u" + ('0000' + cc.toString(16)).substr(-4); } } else { - rv += c; + rv += _c; } continue; @@ -11769,7 +11886,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi simple_rule_count++; caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { - regular_rule_count++; + regular_rule_count++; // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } + routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } @@ -12690,7 +12814,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var minl = Math.max(0, line - 10); var b = a.slice(minl, line + 10); - var _c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); + var _c2 = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); var offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2(_templateObject82(), ex, offendingChunk)); @@ -16978,9 +17102,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 101: /*! Production:: suffix : %epsilon */ - case 117: - /*! Production:: action : %epsilon */ - case 118: /*! Production:: action_body : %epsilon */ @@ -16997,13 +17118,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (rv) { + yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = yyvstack[yysp]; + this.$ = yyvstack[yysp]; + } break; case 6: @@ -17025,16 +17148,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + this.$ = yyvstack[yysp - 1]; - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject94(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + var _rv8 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - yy.addDeclaration(this.$, { - actionInclude: yyvstack[yysp] - }); + if (_rv8) { + yyparser.yyError(rmCommonWS$3(_templateObject94(), _rv8, yylexer.prettyPrintRange(yylstack[yysp]))); + } + + yy.addDeclaration(this.$, { + actionInclude: yyvstack[yysp] + }); + } break; case 9: @@ -17104,15 +17230,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var _rv9 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (_rv9) { + yyparser.yyError(rmCommonWS$3(_templateObject96(), _rv9, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = { - include: yyvstack[yysp] - }; + this.$ = { + include: yyvstack[yysp] + }; + } break; case 17: @@ -17120,15 +17248,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + var _rv10 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject97(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); - } + if (_rv10) { + yyparser.yyError(rmCommonWS$3(_templateObject97(), _rv10, yylexer.prettyPrintRange(yylstack[yysp]))); + } - this.$ = { - include: yyvstack[yysp] - }; + this.$ = { + include: yyvstack[yysp] + }; + } break; case 18: @@ -17228,18 +17358,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); - } + { + var _rv11 = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); - this.$ = { - initCode: { - qualifier: yyvstack[yysp - 1], - include: yyvstack[yysp] + if (_rv11) { + yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, _rv11, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } - }; + + this.$ = { + initCode: { + qualifier: yyvstack[yysp - 1], + include: yyvstack[yysp] + } + }; + } break; case 28: @@ -17341,9 +17473,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 114: /*! Production:: action_ne : include_macro_code */ - case 115: - /*! Production:: action : action_ne */ - case 119: /*! Production:: action_body : action_comments_body */ @@ -17553,23 +17682,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; + { + var _rv12 = []; + var lst = yyvstack[yysp]; + + for (var i = 0, len = lst.length; i < len; i++) { + var id = lst[i]; + var m = { + id: id + }; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = { - id: id - }; + if (yyvstack[yysp - 1]) { + m.type = yyvstack[yysp - 1]; + } - if (yyvstack[yysp - 1]) { - m.type = yyvstack[yysp - 1]; + _rv12.push(m); } - rv.push(m); + this.$ = _rv12; } - - this.$ = rv; break; case 62: @@ -17577,13 +17708,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + var _m = yyvstack[yysp]; - if (yyvstack[yysp - 1]) { - m.type = yyvstack[yysp - 1]; - } + if (yyvstack[yysp - 1]) { + _m.type = yyvstack[yysp - 1]; + } - this.$ = [m]; + this.$ = [_m]; + } break; case 63: @@ -17760,32 +17893,38 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - this.$ = [yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '']; + { + this.$ = [yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '']; - if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + if (yyvstack[yysp]) { + var _rv13 = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject118(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + if (_rv13) { + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3(_templateObject118(), _rv13, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } else { + var indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + yyparser.yyError(rmCommonWS$3(_templateObject119(), _rv13, indentedSrc, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + } + } + + this.$.push(yyvstack[yysp].action); } - this.$.push(yyvstack[yysp]); - } + if (yyvstack[yysp - 1]) { + if (yyvstack[yysp - 2].length === 0) { + yyparser.yyError(rmCommonWS$3(_templateObject120(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] + /* @handle is very probably NULL! We need this one for some decent location info! */ + ))); + } - if (yyvstack[yysp - 1]) { - if (yyvstack[yysp - 2].length === 0) { - yyparser.yyError(rmCommonWS$3(_templateObject119(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] - /* @handle is very probably NULL! We need this one for some decent location info! */ - ))); + this.$.push(yyvstack[yysp - 1]); } - this.$.push(yyvstack[yysp - 1]); - } - - if (this.$.length === 1) { - this.$ = this.$[0]; + if (this.$.length === 1) { + this.$ = this.$[0]; + } } - break; case 88: @@ -17793,22 +17932,29 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = ['']; + { + this.$ = ['']; - if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + if (yyvstack[yysp]) { + var _rv14 = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject120(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); - } + if (_rv14) { + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3(_templateObject121(), _rv14, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } else { + var _indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); - this.$.push(yyvstack[yysp]); - } + yyparser.yyError(rmCommonWS$3(_templateObject122(), _rv14, _indentedSrc, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } + } - if (this.$.length === 1) { - this.$ = this.$[0]; - } + this.$.push(yyvstack[yysp].action); + } + if (this.$.length === 1) { + this.$ = this.$[0]; + } + } break; case 89: @@ -17818,7 +17964,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 90: @@ -17911,7 +18057,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 105: @@ -17931,11 +18077,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 107: - /*! Production:: prec : %epsilon */ + /*! Production:: prec : %epsilon */ + + case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) @@ -17948,7 +18097,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject126(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + break; + + case 115: + /*! Production:: action : action_ne */ + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; break; case 116: @@ -17956,7 +18116,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + var src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: "\n this.$ = (\n ".concat(src, "\n );\n "), + isArrowAction: true + }; + } break; case 120: @@ -17981,7 +18147,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject127(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 126: @@ -17997,17 +18163,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { - encoding: 'utf-8' - }); - var rv = checkActionBlock$2(fileContent); + { + var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { + encoding: 'utf-8' + }); - if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject126(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); - } // And no, we don't support nested '%include': + var _rv15 = checkActionBlock$2(fileContent); + + if (_rv15) { + yyparser.yyError(rmCommonWS$3(_templateObject128(), $PATH, _rv15, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + } // And no, we don't support nested '%include': - this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -18016,7 +18185,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); + yyparser.yyError(rmCommonWS$3(_templateObject129()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); break; case 131: @@ -18026,7 +18195,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject128()) + yylexer.prettyPrintRange(yylstack[yysp])); + yyparser.yyError(rmCommonWS$3(_templateObject130()) + yylexer.prettyPrintRange(yylstack[yysp])); break; } }, @@ -18207,12 +18376,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (recoveringErrorInfo) { var esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); - v.yyError = true; - v.errorRuleDepth = error_rule_depth; - v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; - recoveringErrorInfo.value_stack[esp] = v; + var _v12 = this.shallowCopyErrorInfo(hash); + + _v12.yyError = true; + _v12.errorRuleDepth = error_rule_depth; + _v12.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; + + recoveringErrorInfo.value_stack[esp] = _v12; recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc); recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1]; ++esp; @@ -18337,8 +18508,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.__error_infos.length = 0; - for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { - var _el2 = this.__error_recovery_infos[_i6]; + for (var _i9 = this.__error_recovery_infos.length - 1; _i9 >= 0; _i9--) { + var _el2 = this.__error_recovery_infos[_i9]; if (_el2 && typeof _el2.destroy === 'function') { _el2.destroy(); @@ -18390,8 +18561,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l2) { if (last_index != null) { - for (var _i7 = i2; _i7 >= i1; _i7--) { - l2 = lstack[_i7]; + for (var _i10 = i2; _i10 >= i1; _i10--) { + l2 = lstack[_i10]; if (l2) { break; @@ -18404,8 +18575,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { - l1 = lstack[_i8]; + for (var _i11 = (i1 || sp) - 1; _i11 >= 0; _i11--) { + l1 = lstack[_i11]; if (l1) { break; @@ -21448,7 +21619,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */ - this.warn(rmCommonWS(_templateObject129(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + this.warn(rmCommonWS(_templateObject131(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); yy_.yytext = [// {NAME} this.matches[1], // optional value/parameters this.matches[2].trim()]; @@ -21569,67 +21740,75 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: action */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 82: /*! Conditions:: action */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 83: /*! Conditions:: action */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 84: /*! Conditions:: option_values */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 85: /*! Conditions:: option_values */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject136()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 86: /*! Conditions:: option_values */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject137()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var _rules4 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject139(), _rules4) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + { + var _rules5 = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + + yy_.yyerror(rmCommonWS(_templateObject140(), _rules5) + this.prettyPrintRange(yy_.yylloc)); + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ @@ -21637,7 +21816,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: . */ /* b0rk on bad characters */ - yy_.yyerror(rmCommonWS(_templateObject139(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject141(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); return 2; default: @@ -22095,7 +22274,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var ebnf = false; var rmCommonWS$3 = helpers.rmCommonWS; var dquote$2 = helpers.dquote; - var checkActionBlock$2 = helpers.checkActionBlock; // transform ebnf to bnf if necessary + var checkActionBlock$2 = helpers.checkActionBlock; + var trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary function extend(json, grammar) { if (ebnf) { @@ -22487,7 +22667,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.macros; if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject140())); + lex_pre.push(rmCommonWS$4(_templateObject142())); var keylen = 0; for (var key in src) { @@ -22498,11 +22678,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi keylen = (keylen / 4 | 0) * 4 + 4; console.log('macros keylen B:', keylen); - for (var _key in src) { - lex_pre.push(padRight(_key, keylen) + src[_key]); + for (var _key2 in src) { + lex_pre.push(padRight(_key2, keylen) + src[_key2]); } - lex_pre.push(rmCommonWS$4(_templateObject141())); + lex_pre.push(rmCommonWS$4(_templateObject143())); } } { @@ -22510,16 +22690,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.unknownDecls; if (_src && !isEmptyObj(_src)) { - lex_pre.push(rmCommonWS$4(_templateObject142())); + lex_pre.push(rmCommonWS$4(_templateObject144())); for (var i = 0, len = _src.length; i < len; i++) { var entry = _src[i]; - var _key2 = entry.name; + var _key3 = entry.name; var value = entry.value; - lex_pre.push('%' + _key2 + ' ' + value); + lex_pre.push('%' + _key3 + ' ' + value); } - lex_pre.push(rmCommonWS$4(_templateObject143())); + lex_pre.push(rmCommonWS$4(_templateObject145())); } } { @@ -22527,15 +22707,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.options; if (_src2 && !isEmptyObj(_src2)) { - lex_pre.push(rmCommonWS$4(_templateObject144())); + lex_pre.push(rmCommonWS$4(_templateObject146())); - for (var _key3 in _src2) { - var _value = _src2[_key3]; + for (var _key4 in _src2) { + var _value = _src2[_key4]; if (_value) { - lex_pre.push('%options ' + _key3 + '=' + _value); + lex_pre.push('%options ' + _key4 + '=' + _value); } else { - lex_pre.push('%options ' + _key3); + lex_pre.push('%options ' + _key4); } } } @@ -22545,9 +22725,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.startConditions; if (_src3 && !isEmptyObj(_src3)) { - for (var _key4 in _src3) { - var _value2 = _src3[_key4]; - lex_pre.push((_value2 ? '%x ' : '%s ') + _key4); + for (var _key5 in _src3) { + var _value2 = _src3[_key5]; + lex_pre.push((_value2 ? '%x ' : '%s ') + _key5); } } } @@ -22564,9 +22744,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.lex.rules; if (_src5) { - for (var _i9 = 0, _len2 = _src5.length; _i9 < _len2; _i9++) { - var _entry = _src5[_i9]; - var _key5 = _entry[0]; + for (var _i12 = 0, _len8 = _src5.length; _i12 < _len8; _i12++) { + var _entry = _src5[_i12]; + var _key6 = _entry[0]; var action = indentAction(_entry[1], 4); var actionHasLF = /[\r\n]/.test(action); console.log('indented action:', { @@ -22575,16 +22755,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi actionHasLF: actionHasLF }); - if (_key5.length <= 12) { + if (_key6.length <= 12) { if (!actionHasLF) { - lex_rules.push(padRight(_key5, 16) + indentAction(action, 16)); + lex_rules.push(padRight(_key6, 16) + indentAction(action, 16)); } else { - lex_rules.push(padRight(_key5, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(padRight(_key6, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } else if (!actionHasLF) { - lex_rules.push(_key5, makeIndent(16) + indentAction(action, 16)); + lex_rules.push(_key6, makeIndent(16) + indentAction(action, 16)); } else { - lex_rules.push(_key5, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(_key6, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } @@ -22603,15 +22783,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!isEmptyObj(raw.lex)) { // dump the remainder as a comment: var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4(_templateObject145(), rem.replace(/\*\//g, '*\\/')); + out += rmCommonWS$4(_templateObject147(), rem.replace(/\*\//g, '*\\/')); } delete raw.lex; out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject146()) + lex_rules.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject148()) + lex_rules.join('\n') + '\n\n'; if (lex_post.length > 0) { - out += rmCommonWS$4(_templateObject147()) + lex_post.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject149()) + lex_post.join('\n') + '\n\n'; } lex_out_str = out; @@ -22683,69 +22863,69 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var grammarfmt = function grammarfmt(src) { var dst = []; - for (var _key6 in src) { - var prodset = src[_key6]; + for (var _key7 in src) { + var prodset = src[_key7]; var rule = void 0; console.log('format one rule:', { - key: _key6, + key: _key7, prodset: prodset }); if (typeof prodset === 'string') { - rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; - delete src[_key6]; + rule = fmtprod(_key7 + ' : ', [prodset]) + ';'; + delete src[_key7]; } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; - delete src[_key6]; + rule = fmtprod(_key7 + ' : ', [prodset]) + ';'; + delete src[_key7]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(_key6 + ' : ', prodset[0]); + rule = fmtprod(_key7 + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { - delete src[_key6]; + delete src[_key7]; } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(_key6 + '\n : ', [prodset[0]]); + rule = fmtprod(_key7 + '\n : ', [prodset[0]]); delete prodset[0]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(_key6 + '\n : ', prodset[0]); + rule = fmtprod(_key7 + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var _i10 = 1, _len3 = prodset.length; _i10 < _len3; _i10++) { - if (typeof prodset[_i10] === 'string') { - rule += fmtprod('\n | ', [prodset[_i10]]); - delete prodset[_i10]; - } else if (prodset[_i10] instanceof Array) { - rule += fmtprod('\n | ', prodset[_i10]); + for (var _i13 = 1, _len9 = prodset.length; _i13 < _len9; _i13++) { + if (typeof prodset[_i13] === 'string') { + rule += fmtprod('\n | ', [prodset[_i13]]); + delete prodset[_i13]; + } else if (prodset[_i13] instanceof Array) { + rule += fmtprod('\n | ', prodset[_i13]); - if (prodset[_i10].length === 0) { - delete prodset[_i10]; + if (prodset[_i13].length === 0) { + delete prodset[_i13]; } } else { - rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i10]; + rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i13]; } } rule += '\n ;'; if (isEmptyArr(prodset)) { - delete src[_key6]; + delete src[_key7]; } } } else { - rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; + rule = _key7 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -22781,23 +22961,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete raw.unknownDecls; if (_src9 && !isEmptyObj(_src9)) { - lex_pre.push(rmCommonWS$4(_templateObject148())); + lex_pre.push(rmCommonWS$4(_templateObject150())); - for (var _i11 = 0, _len4 = _src9.length; _i11 < _len4; _i11++) { - var _entry2 = _src9[_i11]; - var _key7 = _entry2.name; + for (var _i14 = 0, _len10 = _src9.length; _i14 < _len10; _i14++) { + var _entry2 = _src9[_i14]; + var _key8 = _entry2.name; var _value3 = _entry2.value; - lex_pre.push('%' + _key7 + ' ' + _value3); + lex_pre.push('%' + _key8 + ' ' + _value3); } - lex_pre.push(rmCommonWS$4(_templateObject149())); + lex_pre.push(rmCommonWS$4(_templateObject151())); } } //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { - grammar_pre.push(rmCommonWS$4(_templateObject150(), lex_out_str)); + grammar_pre.push(rmCommonWS$4(_templateObject152(), lex_out_str)); } { @@ -22807,38 +22987,38 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src10 && !isEmptyObj(_src10)) { var a = []; - for (var _key8 in _src10) { - var _value4 = _src10[_key8]; + for (var _key9 in _src10) { + var _value4 = _src10[_key9]; - switch (_key8) { + switch (_key9) { default: if (_value4 !== true) { - a.push('options', '%options ' + _key8 + '=' + _value4); + a.push('options', '%options ' + _key9 + '=' + _value4); } else { - a.push('options', '%options ' + _key8); + a.push('options', '%options ' + _key9); } break; case 'ebnf': if (_value4) { - a.push(_key8, '%ebnf'); + a.push(_key9, '%ebnf'); } break; case 'type': if (_value4) { - a.push(_key8, '%parser-type ' + _value4); + a.push(_key9, '%parser-type ' + _value4); } break; case 'debug': if (typeof _value4 !== 'boolean') { - a.push(_key8, '%debug ' + _value4); + a.push(_key9, '%debug ' + _value4); } else if (_value4) { - a.push(_key8, '%debug'); + a.push(_key9, '%debug'); } break; @@ -22847,9 +23027,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var type = null; - for (var _i12 = 0, _len5 = a.length; _i12 < _len5; _i12 += 2) { - var t = a[_i12]; - var line = a[_i12 + 1]; + for (var _i15 = 0, _len11 = a.length; _i15 < _len11; _i15 += 2) { + var t = a[_i15]; + var line = a[_i15 + 1]; if (t !== type) { type = t; @@ -22868,14 +23048,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src11) { var clean = true; - for (var _i13 = 0, _len6 = _src11.length; _i13 < _len6; _i13++) { - var _entry3 = _src11[_i13]; + for (var _i16 = 0, _len12 = _src11.length; _i16 < _len12; _i16++) { + var _entry3 = _src11[_i16]; grammar_pre.push('%import ' + _entry3.name + ' ' + _entry3.path); delete _entry3.name; delete _entry3.path; if (isEmptyObj(_entry3)) { - delete _src11[_i13]; + delete _src11[_i16]; } else { clean = false; } @@ -22892,14 +23072,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src12) { var _clean = true; - for (var _i14 = 0, _len7 = _src12.length; _i14 < _len7; _i14++) { - var _entry4 = _src12[_i14]; + for (var _i17 = 0, _len13 = _src12.length; _i17 < _len13; _i17++) { + var _entry4 = _src12[_i17]; grammar_pre.push('%code ' + _entry4.qualifier + ' ' + _entry4.include); delete _entry4.qualifier; delete _entry4.include; if (isEmptyObj(_entry4)) { - delete _src12[_i14]; + delete _src12[_i17]; } else { _clean = false; } @@ -22916,8 +23096,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src13) { var _clean2 = true; - for (var _i15 = 0, _len8 = _src13.length; _i15 < _len8; _i15++) { - var _entry5 = _src13[_i15]; + for (var _i18 = 0, _len14 = _src13.length; _i18 < _len14; _i18++) { + var _entry5 = _src13[_i18]; var tokens = _entry5[1]; var _line = '%' + _entry5[0] + ' '; @@ -22929,7 +23109,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi grammar_pre.push(_line); if (_entry5.length === 2) { - delete _src13[_i15]; + delete _src13[_i18]; } else { _clean2 = false; } @@ -22946,8 +23126,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (_src14) { var _clean3 = true; - for (var _i16 = 0, _len9 = _src14.length; _i16 < _len9; _i16++) { - var _entry6 = _src14[_i16]; + for (var _i19 = 0, _len15 = _src14.length; _i19 < _len15; _i19++) { + var _entry6 = _src14[_i19]; var _line2 = '%token ' + _entry6.id; @@ -22970,7 +23150,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi delete _entry6.id; if (isEmptyObj(_entry6)) { - delete _src14[_i16]; + delete _src14[_i19]; } else { _clean3 = false; } @@ -23020,14 +23200,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // dump the remainder as a comment: var _rem = JSON5__default['default'].stringify(raw, null, 2); - _out += rmCommonWS$4(_templateObject151(), _rem.replace(/\*\//g, '*\\/')); // delete raw; + _out += rmCommonWS$4(_templateObject153(), _rem.replace(/\*\//g, '*\\/')); // delete raw; } if (!options.showParser) { _out += lex_out_str; } else { _out += grammar_pre.join('\n') + '\n\n'; - _out += rmCommonWS$4(_templateObject152()); + _out += rmCommonWS$4(_templateObject154()); if (grammar_mid.length > 0) { _out += grammar_mid.join('\n') + '\n\n'; @@ -23042,7 +23222,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return '// ' + line; }); - _out += rmCommonWS$4(_templateObject153(), _a2.join('\n')); + _out += rmCommonWS$4(_templateObject155(), _a2.join('\n')); } _out += ebnf_rules.join('\n\n') + '\n\n'; @@ -23051,7 +23231,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (grammar_post.length > 0) { - _out += rmCommonWS$4(_templateObject154()) + grammar_post.join('\n') + '\n\n'; + _out += rmCommonWS$4(_templateObject156()) + grammar_post.join('\n') + '\n\n'; } } @@ -23060,7 +23240,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return '// ' + line; }); - _out = rmCommonWS$4(_templateObject155(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 + _out = rmCommonWS$4(_templateObject157(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 raw = deepClone(originalInput); @@ -23197,8 +23377,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var opts = {}; //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - for (var _len10 = arguments.length, args = new Array(_len10), _key9 = 0; _key9 < _len10; _key9++) { - args[_key9] = arguments[_key9]; + for (var _len16 = arguments.length, args = new Array(_len16), _key10 = 0; _key10 < _len16; _key10++) { + args[_key10] = arguments[_key10]; } if (args[0] !== 'NODEFAULT') { @@ -24092,7 +24272,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi assert__default['default'](p.handle); var rhs = p.handle; - for (var j = 0, _len11 = rhs.length; j < _len11; j++) { + for (var j = 0, _len17 = rhs.length; j < _len17; j++) { var sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); @@ -24337,8 +24517,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (var _i17 = 0; _i17 < rhs.length; _i17++) { - var _sym = rhs[_i17]; + for (var _i20 = 0; _i20 < rhs.length; _i20++) { + var _sym = rhs[_i20]; if (!bnf[_sym] && _sym.length <= maxlen) { addSymbol(_sym); @@ -24590,13 +24770,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (var _i18 = 0; _i18 < rhs.length; _i18++) { - if (rhs[_i18] === 'error') { + for (var _i21 = 0; _i21 < rhs.length; _i21++) { + if (rhs[_i21] === 'error') { hasErrorRecovery = true; } - assert__default['default'](bnf[rhs[_i18]] ? symbols_[rhs[_i18]] : true, 'all nonterminals must already exist in the symbol table'); - assert__default['default'](rhs[_i18] ? symbols_[rhs[_i18]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); + assert__default['default'](bnf[rhs[_i21]] ? symbols_[rhs[_i21]] : true, 'all nonterminals must already exist in the symbol table'); + assert__default['default'](rhs[_i21] ? symbols_[rhs[_i21]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); } } @@ -24610,23 +24790,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var prec_symbols = []; var winning_symbol; - for (var _i19 = r.handle.length - 1; _i19 >= 0; _i19--) { - if (!(r.handle[_i19] in nonterminals) && r.handle[_i19] in operators) { + for (var _i22 = r.handle.length - 1; _i22 >= 0; _i22--) { + if (!(r.handle[_i22] in nonterminals) && r.handle[_i22] in operators) { var old_prec = r.precedence; - var new_prec = operators[r.handle[_i19]].precedence; + var new_prec = operators[r.handle[_i22]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { - prec_symbols.push(r.handle[_i19]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], this.symbol, handle[0]); + prec_symbols.push(r.handle[_i22]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], this.symbol, handle[0]); if (new_prec < old_prec) { - winning_symbol = r.handle[_i19]; + winning_symbol = r.handle[_i22]; } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { - prec_symbols.push(r.handle[_i19]); - winning_symbol = r.handle[_i19]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); + prec_symbols.push(r.handle[_i22]); + winning_symbol = r.handle[_i22]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; @@ -24717,7 +24897,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var dqpos, sqpos, ccmtpos, cppcmtpos; var first = -1; - for (var _c2 = 0;; _c2++) { + for (var _c3 = 0;; _c3++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); // also look for remaining comments which contain quotes of any kind, @@ -25122,7 +25302,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi moduleInit.getInitCodeSection = function getInitCodeSection(section) { var rv = []; - for (var i = 0, _len12 = this.length; i < _len12; i++) { + for (var i = 0, _len18 = this.length; i < _len18; i++) { var m = this[i]; if (m.qualifier === section) { @@ -25140,11 +25320,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { var rv = []; - for (var i = 0, _len13 = this.length; i < _len13; i++) { + for (var i = 0, _len19 = this.length; i < _len19; i++) { var m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { - rv.push(rmCommonWS$5(_templateObject156(), m.qualifier, m.include, m.qualifier)); + rv.push(rmCommonWS$5(_templateObject158(), m.qualifier, m.include, m.qualifier)); this.__consumedInitCodeSlots__[i] = true; } } @@ -25329,13 +25509,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - for (var _i20 = 0; _i20 < rhs.length; _i20++) { + for (var _i23 = 0; _i23 < rhs.length; _i23++) { // check for aliased names, e.g., id[alias] - var _rhs_i = aliased[_i20]; - addName(_rhs_i, _i20); + var _rhs_i = aliased[_i23]; + addName(_rhs_i, _i23); - if (_rhs_i !== rhs[_i20]) { - addName(rhs[_i20], _i20); + if (_rhs_i !== rhs[_i23]) { + addName(rhs[_i23], _i23); } } @@ -25687,6 +25867,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi default_action.push("// END of default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, ")")); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } + default_action.push('\n', action); } @@ -26674,12 +26861,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - out.push(rmCommonWS$5(_templateObject157(), moduleImportsAsCode, moduleNameAsCode.trim())); + out.push(rmCommonWS$5(_templateObject159(), moduleImportsAsCode, moduleNameAsCode.trim())); exportMain = 'main: yyExecMain,'; - invokeMain = rmCommonWS$5(_templateObject158()); + invokeMain = rmCommonWS$5(_templateObject160()); } - out.push(rmCommonWS$5(_templateObject159(), invokeMain, exportMain)); + out.push(rmCommonWS$5(_templateObject161(), invokeMain, exportMain)); var src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; @@ -26693,10 +26880,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - main = rmCommonWS$5(_templateObject160(), moduleImportsAsCode, moduleNameAsCode.trim()); + main = rmCommonWS$5(_templateObject162(), moduleImportsAsCode, moduleNameAsCode.trim()); } - var out = this.generateModule(opt) + rmCommonWS$5(_templateObject161(), moduleName, moduleName, moduleName, moduleName, main); + var out = this.generateModule(opt) + rmCommonWS$5(_templateObject163(), moduleName, moduleName, moduleName, moduleName, main); opt.exportSourceCode.all = out; return out; }; @@ -27086,9 +27273,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var wsi2 = new Array(max_k_len + 1).join(' '); // generate the member assignment list for the `sharedState_yy` object which will store the `parseParams` for everyone to access - for (var _i21 = 0, _len14 = arglist.length; _i21 < _len14; _i21++) { - var _k = arglist[_i21]; - s += '\n' + ws + _k + ': ' + _k + (_i21 < _len14 - 1 ? ',' + wsi2.substr(0, max_k_len - _k.length - 1) : wsi2.substr(0, max_k_len - _k.length)) + ' // parseParams::' + _k; + for (var _i24 = 0, _len20 = arglist.length; _i24 < _len20; _i24++) { + var _k = arglist[_i24]; + s += '\n' + ws + _k + ': ' + _k + (_i24 < _len20 - 1 ? ',' + wsi2.substr(0, max_k_len - _k.length - 1) : wsi2.substr(0, max_k_len - _k.length)) + ' // parseParams::' + _k; } return s; @@ -27272,8 +27459,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi for (var i = 0, len = a.length; i < len; i++) { var k = a[i]; - var v = tbl[k]; - nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys + var _v13 = tbl[k]; + nt[_v13] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -27893,15 +28080,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var line = []; line.push('║'); - for (var _c3 in def_arr) { - var _key10 = clip(_c3, col_width); + for (var _c4 in def_arr) { + var _key11 = clip(_c4, col_width); var delta = clip('∆', col_delta_width); - line.push(_key10); + line.push(_key11); line.push('┊'); line.push(delta); line.push('║'); - track_prev4delta[_c3] = 10000000; + track_prev4delta[_c4] = 10000000; } report.push(line.join('')); @@ -27910,30 +28097,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi line = []; line.push('║'); - for (var _c4 in def_arr) { + for (var _c5 in def_arr) { var val = void 0, delta_val = void 0; - var tbl = def_arr[_c4]; + var tbl = def_arr[_c5]; if (tbl.length > i) { val = tbl[i] || 0; - delta_val = val - track_prev4delta[_c4]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: + delta_val = val - track_prev4delta[_c5]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: if (delta_val < 0) { delta_val = -val - 1; // so that absolute 0 becomes -1, so it can be recognized from delta=0 ('no change') } - track_prev4delta[_c4] = val; + track_prev4delta[_c5] = val; } else { val = '.'; delta_val = '.'; } - var _key11 = clip(val, col_width); + var _key12 = clip(val, col_width); var _delta = clip(delta_val, col_delta_width); - line.push(_key11); + line.push(_key12); line.push('┊'); line.push(_delta); line.push('║'); @@ -28072,18 +28259,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi for (var i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + var _v14 = col[i]; var j = void 0; for (j = i + 1; j < len; j++) { - if (col[j] !== v) { + if (col[j] !== _v14) { break; } } var runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; + var delta = col[i + 1] - _v14; var steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -28131,18 +28318,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { - rv.push(v); + rv.push(_v14); } else if (optimum_gain === gain[0]) { - rv.push('s', '[' + v + ', ' + runlength + ']'); + rv.push('s', '[' + _v14 + ', ' + runlength + ']'); i += runlength - 1; } else if (optimum_gain === gain[1]) { - rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); + rv.push('s', '[' + _v14 + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; } else { - rv.push(v); //assert(0); // should never get here! + rv.push(_v14); //assert(0); // should never get here! } if (optimum_gain > 0) { @@ -28208,7 +28395,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // default main method for generated commonjs modules - var commonJsMain = "\nfunction __jison_default_main__(args) {\n // When the parser comes with its own `main` function, then use that one:\n if (typeof exports.parser.main === 'function') {\n return exports.parser.main(args);\n }\n\n if (!args[1]) {\n console.log('Usage:', path.basename(args[0]) + ' FILE');\n process.exit(1);\n }\n const source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n const dst = exports.parser.parse(source);\n console.log('parser output:\\n\\n', {\n type: typeof dst,\n value: dst\n });\n try {\n console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2));\n } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ }\n let rv = 0;\n if (typeof dst === 'number' || typeof dst === 'boolean') {\n rv = dst;\n }\n return dst;\n}\n"; // --- END of commonJsMain chunk --- + var commonJsMain = "\nfunction __jison_default_main__(args) {\n // When the parser comes with its own `main` function, then use that one:\n if (typeof exports.parser.main === 'function') {\n return exports.parser.main(args);\n }\n\n if (!args[1]) {\n console.log('Usage:', path.basename(args[0]) + ' FILE');\n process.exit(1);\n }\n const source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n const dst = exports.parser.parse(source);\n console.log('parser output:\\n\\n', {\n type: typeof dst,\n value: dst\n });\n try {\n console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2));\n } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ }\n let rv = 0;\n if (typeof dst === 'number' || typeof dst === 'boolean') {\n rv = dst;\n }\n return dst;\n}\n"; // --- END of commonJsMain chunk --- var commonJsMainImports = "\nconst fs = require('fs');\nconst path = require('path');\n"; // debug mixin for LR parser generators @@ -28256,7 +28443,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi generatorMixin.createParser = function createParser() { var sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5(_templateObject162(), sourceCodeDef.init, sourceCodeDef.src); + var sourcecode = rmCommonWS$5(_templateObject164(), sourceCodeDef.init, sourceCodeDef.src); var p = code_exec$1(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { //console.log("===============================PARSER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$3(sourcecode); diff --git a/dist/jison-umd.js b/dist/jison-umd.js index 8b2930fd9..d6b9eb996 100644 --- a/dist/jison-umd.js +++ b/dist/jison-umd.js @@ -2798,20 +2798,21 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2821,6 +2822,7 @@ delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2970,6 +2972,7 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2978,9 +2981,9 @@ break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -3027,6 +3030,7 @@ break; } } + } break; case 9: @@ -3111,8 +3115,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -3120,6 +3125,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -3150,8 +3156,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -3159,6 +3166,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -3189,9 +3197,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3203,6 +3212,7 @@ yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -3228,8 +3238,6 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3250,8 +3258,9 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3266,6 +3275,7 @@ ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3276,11 +3286,13 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3325,10 +3337,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3357,6 +3370,7 @@ type: 'imports', body: body }; + } break; case 24: @@ -3390,10 +3404,11 @@ // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3415,8 +3430,8 @@ `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3432,6 +3447,7 @@ include: srcCode } }; + } break; case 26: @@ -3443,9 +3459,10 @@ // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3459,6 +3476,7 @@ Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3671,9 +3689,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3685,6 +3704,7 @@ yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3708,8 +3728,8 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3720,6 +3740,7 @@ ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3730,13 +3751,14 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3766,6 +3788,7 @@ `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3931,8 +3954,9 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3942,6 +3966,7 @@ `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3952,7 +3977,8 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3970,7 +3996,7 @@ srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3985,6 +4011,7 @@ } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -4230,9 +4257,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4260,6 +4288,7 @@ // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4271,8 +4300,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4287,6 +4317,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4297,6 +4328,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4351,13 +4383,14 @@ } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4645,10 +4678,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4659,8 +4694,10 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4671,6 +4708,7 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4681,7 +4719,7 @@ `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4698,6 +4736,7 @@ } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4793,7 +4832,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4806,6 +4846,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4816,6 +4857,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$2(yyvstack[yysp]); @@ -4824,7 +4866,7 @@ // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4841,6 +4883,7 @@ } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4851,11 +4894,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4869,6 +4913,7 @@ ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4912,9 +4957,10 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4925,6 +4971,7 @@ } } this.$ = srcCode; + } break; case 126: @@ -4976,9 +5023,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4992,6 +5040,7 @@ // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -5002,8 +5051,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -5014,6 +5063,7 @@ ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -5037,10 +5087,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -5069,11 +5120,11 @@ } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -5085,6 +5136,7 @@ } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -10234,21 +10286,22 @@ case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10342,55 +10395,55 @@ case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10398,24 +10451,25 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10443,44 +10497,45 @@ case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10605,38 +10660,39 @@ case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10676,29 +10732,30 @@ case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10802,49 +10859,56 @@ case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10858,7 +10922,8 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11435,9 +11500,9 @@ } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11446,9 +11511,9 @@ // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11456,7 +11521,7 @@ // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11466,11 +11531,11 @@ spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11486,15 +11551,15 @@ // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11554,11 +11619,11 @@ }(); parser.lexer = lexer; - var rmCommonWS$1 = helpers.rmCommonWS; - var checkActionBlock$1 = helpers.checkActionBlock; - var mkIdentifier$2 = helpers.mkIdentifier; - var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; - var trimActionCode$1 = helpers.trimActionCode; + const rmCommonWS$1 = helpers.rmCommonWS; + const checkActionBlock$1 = helpers.checkActionBlock; + const mkIdentifier$2 = helpers.mkIdentifier; + const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; + const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11599,11 +11664,11 @@ // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. - var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; + const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11613,7 +11678,7 @@ function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11622,10 +11687,10 @@ } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11635,7 +11700,7 @@ rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11648,7 +11713,7 @@ // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11670,35 +11735,35 @@ } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11712,19 +11777,19 @@ default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11755,7 +11820,7 @@ // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -13141,6 +13206,12 @@ caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } @@ -20860,8 +20931,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /*! Production:: optional_end_block : %epsilon */ case 101: /*! Production:: suffix : %epsilon */ - case 117: - /*! Production:: action : %epsilon */ case 118: /*! Production:: action_body : %epsilon */ case 133: @@ -20883,7 +20952,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} @@ -20893,6 +20963,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } this.$ = yyvstack[yysp]; + } break; case 6: @@ -20918,8 +20989,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -20929,6 +21001,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } yy.addDeclaration(this.$, { actionInclude: yyvstack[yysp] }); + } break; case 9: @@ -21012,7 +21085,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action code block does not compile: ${rv} @@ -21022,6 +21096,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } this.$ = {include: yyvstack[yysp]}; + } break; case 17: @@ -21032,7 +21107,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` action header code block does not compile: ${rv} @@ -21042,6 +21118,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } this.$ = {include: yyvstack[yysp]}; + } break; case 18: @@ -21168,7 +21245,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$3` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} @@ -21183,6 +21261,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; include: yyvstack[yysp] } }; + } break; case 28: @@ -21298,8 +21377,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /*! Production:: action_ne : ACTION */ case 114: /*! Production:: action_ne : include_macro_code */ - case 115: - /*! Production:: action : action_ne */ case 119: /*! Production:: action_body : action_comments_body */ case 123: @@ -21599,17 +21676,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = {id: id}; + { + let rv = []; + let lst = yyvstack[yysp]; + for (let i = 0, len = lst.length; i < len; i++) { + let id = lst[i]; + let m = {id: id}; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } rv.push(m); } this.$ = rv; + } break; case 62: @@ -21620,11 +21699,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + let m = yyvstack[yysp]; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } this.$ = [m]; + } break; case 63: @@ -21902,18 +21983,37 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { this.$ = [(yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '')]; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { @@ -21929,6 +22029,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 88: @@ -21939,22 +22040,42 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = ['']; if (yyvstack[yysp]) { - var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$2(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3` - epsilon production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$3` + epsilon production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } else { + let indentedSrc = rmCommonWS$3([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$3` + epsilon production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 89: @@ -22135,6 +22256,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 107: /*! Production:: prec : %epsilon */ + case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); @@ -22161,6 +22284,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); break; + case 115: + /*! Production:: action : action_ne */ + + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; + break; + case 116: /*! Production:: action : ARROW_ACTION */ @@ -22169,7 +22306,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + let src = trimActionCode$2(yyvstack[yysp]); + this.$ = { + action: ` + this.$ = ( + ${src} + ); + `, + isArrowAction: true + }; + } break; case 120: @@ -22230,8 +22377,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); - var rv = checkActionBlock$2(fileContent); + { + let fileContent = fs__default['default'].readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); + let rv = checkActionBlock$2(fileContent); if (rv) { yyparser.yyError(rmCommonWS$3` included action code file "${$PATH}" does not compile: ${rv} @@ -22242,6 +22390,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And no, we don't support nested '%include': this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -27457,42 +27606,48 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ /*! Rule:: . */ @@ -28026,13 +28181,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; // unescape a string value which is wrapped in quotes/doublequotes function unescQuote(str) { str = '' + str; - var a = str.split('\\\\'); + let a = str.split('\\\\'); a = a.map(function(s) { return s.replace(/\\'/g, '\'').replace(/\\"/g, '"'); @@ -28068,9 +28223,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - var rmCommonWS$3 = helpers.rmCommonWS; - var dquote$2 = helpers.dquote; - var checkActionBlock$2 = helpers.checkActionBlock; + const rmCommonWS$3 = helpers.rmCommonWS; + const dquote$2 = helpers.dquote; + const checkActionBlock$2 = helpers.checkActionBlock; + const trimActionCode$2 = helpers.trimActionCode; // transform ebnf to bnf if necessary @@ -28101,7 +28257,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -31845,6 +32001,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; default_action.push(`// END of default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags})`); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } default_action.push('\n', action); } action = default_action.join('\n'); @@ -35258,9 +35420,9 @@ function __jison_default_main__(args) { try { console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2)); } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ } - let rv = 0; - if (typeof dst === 'number' || typeof dst === 'boolean') { - rv = dst; + let rv = 0; + if (typeof dst === 'number' || typeof dst === 'boolean') { + rv = dst; } return dst; } diff --git a/examples/Makefile b/examples/Makefile index 44fd01361..7879a0180 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -5,10 +5,10 @@ NYC = ../node_modules/.bin/nyc --clean=false --temp-directory ../.nyc_output ifndef FULL_CODE_COVERAGE - JISON = node ../dist/cli-cjs-es5.js -o ./output/$@/ + JISON = node ../dist/cli-cjs.js -o ./output/$@/ NODE = node else - JISON = $(NYC) --reporter=lcov -- node ../dist/cli-cjs-es5.js -o ./output/$@/ + JISON = $(NYC) --reporter=lcov -- node ../dist/cli-cjs.js -o ./output/$@/ NODE = $(NYC) --reporter=lcov -- node endif @@ -32,11 +32,7 @@ ERROR_HANDLING_TARGETS = \ GITHUB_ISSUE_TARGETS = \ - issue-51-gho-1 \ - issue-51-gho-2 \ - issue-51-gho-3 \ - issue-51-gho-4 \ - issue-51-gho-5 \ + issue-51-gho \ issue-58-gho \ issue-205 \ issue-205-2 \ @@ -347,25 +343,37 @@ handlebars: inherited_y: $(JISON) --main ./inherited.y +issue-51-gho: \ + issue-51-gho-1 \ + issue-51-gho-2 \ + issue-51-gho-3 \ + issue-51-gho-4 \ + issue-51-gho-5 \ + issue-51-gho-6 + issue-51-gho-1: - $(JISON) --main ./$@.jison - $(NODE) ./output/$@/$@.js + $(JISON) --main ./$@.jison ./issue-51-gho.jisonlex + $(NODE) ./output/$@/$@.js ./issue-51-gho.input issue-51-gho-2: - $(JISON) --main ./$@.jison - $(NODE) ./output/$@/$@.js + -$(JISON) --main ./$@.jison ./issue-51-gho.jisonlex + -$(NODE) ./output/$@/$@.js ./issue-51-gho.input issue-51-gho-3: - $(JISON) --main ./$@.jison - $(NODE) ./output/$@/$@.js + -$(JISON) --main ./$@.jison ./issue-51-gho.jisonlex + -$(NODE) ./output/$@/$@.js ./issue-51-gho.input issue-51-gho-4: - $(JISON) --main ./$@.jison - $(NODE) ./output/$@/$@.js + $(JISON) --main ./$@.jison ./issue-51-gho.jisonlex + $(NODE) ./output/$@/$@.js ./issue-51-gho.input issue-51-gho-5: - $(JISON) --main ./$@.jison - $(NODE) ./output/$@/$@.js + $(JISON) --main ./$@.jison ./issue-51-gho.jisonlex + $(NODE) ./output/$@/$@.js ./issue-51-gho.input + +issue-51-gho-6: + $(JISON) --main ./$@.jison ./issue-51-gho.jisonlex + $(NODE) ./output/$@/$@.js ./issue-51-gho.input issue-58-gho: $(NODE) ./$@.make.js diff --git a/examples/issue-51-gho-1.jison b/examples/issue-51-gho-1.jison index a569cb020..94494014b 100644 --- a/examples/issue-51-gho-1.jison +++ b/examples/issue-51-gho-1.jison @@ -1,7 +1,9 @@ // GOOD +// +// https://github.com/GerHobbelt/jison/issues/51 %% -expr: 'foo' -> 1 // comment +expr: 'foo' -> 42 // comment ; diff --git a/examples/issue-51-gho-2.jison b/examples/issue-51-gho-2.jison index bb42b5650..caba84b53 100644 --- a/examples/issue-51-gho-2.jison +++ b/examples/issue-51-gho-2.jison @@ -1,7 +1,9 @@ // GOOD +// +// https://github.com/GerHobbelt/jison/issues/51 %% -expr: 'foo' -> 1; // comment +expr: 'foo' -> 42; // comment diff --git a/examples/issue-51-gho-3.jison b/examples/issue-51-gho-3.jison index efc1fcfa6..2b29d6ddd 100644 --- a/examples/issue-51-gho-3.jison +++ b/examples/issue-51-gho-3.jison @@ -1,7 +1,9 @@ // BAD +// +// https://github.com/GerHobbelt/jison/issues/51 %% -expr: 'foo' -> 1; // comment +expr: 'foo' -> 42; // comment ; diff --git a/examples/issue-51-gho-4.jison b/examples/issue-51-gho-4.jison index d9bd6aa5a..ec557f50e 100644 --- a/examples/issue-51-gho-4.jison +++ b/examples/issue-51-gho-4.jison @@ -1,7 +1,10 @@ // GOOD +// +// https://github.com/GerHobbelt/jison/issues/51 %% -expr: 'foo' -> { return 1 // comment } +expr: 'foo' -> { 42 // comment + } ; diff --git a/examples/issue-51-gho-5.jison b/examples/issue-51-gho-5.jison index c08da1ddb..cce9ab264 100644 --- a/examples/issue-51-gho-5.jison +++ b/examples/issue-51-gho-5.jison @@ -1,7 +1,10 @@ // GOOD +// +// https://github.com/GerHobbelt/jison/issues/51 %% -expr: 'foo' -> { return 1; // comment } +expr: 'foo' -> { 42; // comment + } ; diff --git a/lib/jison-parser-commonJsMain-function.js b/lib/jison-parser-commonJsMain-function.js index 2c1db492a..7760323a0 100644 --- a/lib/jison-parser-commonJsMain-function.js +++ b/lib/jison-parser-commonJsMain-function.js @@ -18,9 +18,9 @@ function __jison_default_main__(args) { try { console.log('\n\nor as JSON:\n', JSON.stringify(dst, null, 2)); } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ } - let rv = 0; - if (typeof dst === 'number' || typeof dst === 'boolean') { - rv = dst; + let rv = 0; + if (typeof dst === 'number' || typeof dst === 'boolean') { + rv = dst; } return dst; } diff --git a/lib/jison.js b/lib/jison.js index e88b996ed..a0e4b3439 100755 --- a/lib/jison.js +++ b/lib/jison.js @@ -2839,6 +2839,12 @@ generator.buildProductionActions = function buildProductionActions() { default_action.push(`// END of default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags})`); if (action.trim() !== '') { + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } default_action.push('\n', action); } action = default_action.join('\n'); @@ -6282,9 +6288,9 @@ function __jison_default_main__(args) { try { console.log('\\n\\nor as JSON:\\n', JSON.stringify(dst, null, 2)); } catch (e) { /* ignore crashes; output MAY not be serializable! We are a generic bit of code, after all... */ } - let rv = 0; - if (typeof dst === 'number' || typeof dst === 'boolean') { - rv = dst; + let rv = 0; + if (typeof dst === 'number' || typeof dst === 'boolean') { + rv = dst; } return dst; } diff --git a/packages/ebnf-parser/bnf.l b/packages/ebnf-parser/bnf.l index 5d722f104..9a2db7b30 100644 --- a/packages/ebnf-parser/bnf.l +++ b/packages/ebnf-parser/bnf.l @@ -273,7 +273,7 @@ LEX_CONTENT {WS}*(?:{BR}[^]*?)?{BR}{WS}* ` + this.prettyPrintRange(yylloc)); return 'UNTERMINATED_STRING_ERROR'; -<*>\" var rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); +<*>\" let rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. @@ -281,7 +281,7 @@ LEX_CONTENT {WS}*(?:{BR}[^]*?)?{BR}{WS}* Erroneous area: ` + this.prettyPrintRange(yylloc)); return 'UNTERMINATED_STRING_ERROR'; -<*>\' var rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); +<*>\' let rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. @@ -289,7 +289,7 @@ LEX_CONTENT {WS}*(?:{BR}[^]*?)?{BR}{WS}* Erroneous area: ` + this.prettyPrintRange(yylloc)); return 'UNTERMINATED_STRING_ERROR'; -<*>\` var rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); +<*>\` let rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. @@ -315,20 +315,20 @@ LEX_CONTENT {WS}*(?:{BR}[^]*?)?{BR}{WS}* %% -var rmCommonWS = helpers.rmCommonWS; -var dquote = helpers.dquote; +const rmCommonWS = helpers.rmCommonWS; +const dquote = helpers.dquote; function indent(s, i) { - var a = s.split('\n'); - var pf = (new Array(i + 1)).join(' '); + let a = s.split('\n'); + let pf = (new Array(i + 1)).join(' '); return pf + a.join('\n' + pf); } // unescape a string value which is wrapped in quotes/doublequotes function unescQuote(str) { str = '' + str; - var a = str.split('\\\\'); + let a = str.split('\\\\'); a = a.map(function (s) { return s.replace(/\\'/g, "'").replace(/\\"/g, '"'); }); diff --git a/packages/ebnf-parser/bnf.y b/packages/ebnf-parser/bnf.y index c942e3a5a..4566eb457 100644 --- a/packages/ebnf-parser/bnf.y +++ b/packages/ebnf-parser/bnf.y @@ -94,7 +94,7 @@ optional_end_block { $$ = ''; } | '%%' extra_parser_module_code { - var rv = checkActionBlock($extra_parser_module_code, @extra_parser_module_code); + let rv = checkActionBlock($extra_parser_module_code, @extra_parser_module_code); if (rv) { yyerror(rmCommonWS` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} @@ -113,7 +113,7 @@ optional_action_header_block | optional_action_header_block ACTION { $$ = $optional_action_header_block; - var rv = checkActionBlock($ACTION, @ACTION); + let rv = checkActionBlock($ACTION, @ACTION); if (rv) { yyerror(rmCommonWS` action header code block does not compile: ${rv} @@ -127,7 +127,7 @@ optional_action_header_block | optional_action_header_block include_macro_code { $$ = $optional_action_header_block; - var rv = checkActionBlock($include_macro_code, @include_macro_code); + let rv = checkActionBlock($include_macro_code, @include_macro_code); if (rv) { yyerror(rmCommonWS` action header code block does not compile: ${rv} @@ -168,7 +168,7 @@ declaration { $$ = {token_list: $full_token_definitions}; } | ACTION { - var rv = checkActionBlock($ACTION, @ACTION); + let rv = checkActionBlock($ACTION, @ACTION); if (rv) { yyerror(rmCommonWS` action code block does not compile: ${rv} @@ -181,7 +181,7 @@ declaration } | include_macro_code { - var rv = checkActionBlock($include_macro_code, @include_macro_code); + let rv = checkActionBlock($include_macro_code, @include_macro_code); if (rv) { yyerror(rmCommonWS` action header code block does not compile: ${rv} @@ -239,7 +239,7 @@ declaration } | INIT_CODE init_code_name action_ne { - var rv = checkActionBlock($action_ne, @action_ne); + let rv = checkActionBlock($action_ne, @action_ne); if (rv) { yyerror(rmCommonWS` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} @@ -459,11 +459,11 @@ token_list full_token_definitions : optional_token_type id_list { - var rv = []; - var lst = $id_list; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = {id: id}; + let rv = []; + let lst = $id_list; + for (let i = 0, len = lst.length; i < len; i++) { + let id = lst[i]; + let m = {id: id}; if ($optional_token_type) { m.type = $optional_token_type; } @@ -473,7 +473,7 @@ full_token_definitions } | optional_token_type one_full_token { - var m = $one_full_token; + let m = $one_full_token; if ($optional_token_type) { m.type = $optional_token_type; } @@ -677,16 +677,34 @@ handle_action { $$ = [($handle.length ? $handle.join(' ') : '')]; if ($action) { - var rv = checkActionBlock($action, @action); + let rv = checkActionBlock($action.action, @action); if (rv) { - yyerror(rmCommonWS` - production rule action code block does not compile: ${rv} - - Erroneous area: - ${yylexer.prettyPrintRange(@action, @handle)} - `); + if (!$action.isArrowAction) { + yyerror(rmCommonWS` + production rule action code block does not compile: ${rv} + + Erroneous area: + ${yylexer.prettyPrintRange(@action, @handle)} + `); + } else { + let indentedSrc = rmCommonWS([$action.action]).split('\n').join('\n '); + + yyerror(rmCommonWS` + production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(@action, @handle)} + `); + } } - $$.push($action); + $$.push($action.action); } if ($prec) { if ($handle.length === 0) { @@ -710,16 +728,34 @@ handle_action { $$ = ['']; if ($action) { - var rv = checkActionBlock($action, @action); + let rv = checkActionBlock($action.action, @action); if (rv) { - yyerror(rmCommonWS` - epsilon production rule action code block does not compile: ${rv} - - Erroneous area: - ${yylexer.prettyPrintRange(@action, @EPSILON)} - `); + if (!$action.isArrowAction) { + yyerror(rmCommonWS` + epsilon production rule action code block does not compile: ${rv} + + Erroneous area: + ${yylexer.prettyPrintRange(@action, @EPSILON)} + `); + } else { + let indentedSrc = rmCommonWS([$action.action]).split('\n').join('\n '); + + yyerror(rmCommonWS` + epsilon production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(@action, @EPSILON)} + `); + } } - $$.push($action); + $$.push($action.action); } if ($$.length === 1) { $$ = $$[0]; @@ -871,14 +907,42 @@ action_ne action : action_ne - { $$ = $action_ne; } + { + $$ = { + action: $action_ne, + isArrowAction: false + }; + } | ARROW_ACTION + // **TODO**: + // // 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. - { $$ = '$$ = (\n' + $ARROW_ACTION + '\n);'; } + // + // But only do so when the arrow action is not itself surrounded by curly braces + // when it would, for instance, attempt to return an object instance. + // + // Also nuke the possible superfluous semicolon, but *only* when it's in + // the outer-most scope as the user may be defining an IIFE or *function* + // as a return value! + // + // Yeah, this stuff can get pretty hairy! |:-\ + { + let src = trimActionCode($ARROW_ACTION); + $$ = { + action: ` + $$ = ( + ${src} + ); + `, + isArrowAction: true + }; + } | %epsilon - { $$ = ''; } + { + $$ = null; + } ; action_body @@ -922,8 +986,8 @@ extra_parser_module_code include_macro_code : INCLUDE PATH { - var fileContent = fs.readFileSync($PATH, { encoding: 'utf-8' }); - var rv = checkActionBlock(fileContent); + let fileContent = fs.readFileSync($PATH, { encoding: 'utf-8' }); + let rv = checkActionBlock(fileContent); if (rv) { yyerror(rmCommonWS` included action code file "${$PATH}" does not compile: ${rv} @@ -971,9 +1035,10 @@ optional_module_code_chunk %% -var rmCommonWS = helpers.rmCommonWS; -var dquote = helpers.dquote; -var checkActionBlock = helpers.checkActionBlock; +const rmCommonWS = helpers.rmCommonWS; +const dquote = helpers.dquote; +const checkActionBlock = helpers.checkActionBlock; +const trimActionCode = helpers.trimActionCode; // transform ebnf to bnf if necessary @@ -1004,7 +1069,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/ebnf-parser/dist/ebnf-parser-cjs-es5.js b/packages/ebnf-parser/dist/ebnf-parser-cjs-es5.js index 60e3d8e3e..847a2179b 100644 --- a/packages/ebnf-parser/dist/ebnf-parser-cjs-es5.js +++ b/packages/ebnf-parser/dist/ebnf-parser-cjs-es5.js @@ -1767,25 +1767,25 @@ yyparser.yyError(rmCommonWS$1` Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-2])} - `);break;case 4:/*! Production:: optional_end_block : %epsilon */case 101:/*! Production:: suffix : %epsilon */case 117:/*! Production:: action : %epsilon */case 118:/*! Production:: action_body : %epsilon */case 133:/*! Production:: optional_module_code_chunk : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): + `);break;case 4:/*! Production:: optional_end_block : %epsilon */case 101:/*! Production:: suffix : %epsilon */case 118:/*! Production:: action_body : %epsilon */case 133:/*! Production:: optional_module_code_chunk : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 5:/*! Production:: optional_end_block : "%%" extra_parser_module_code */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);}this.$=yyvstack[yysp];break;case 6:/*! Production:: optional_action_header_block : %epsilon */case 10:/*! Production:: declaration_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp];}break;case 6:/*! Production:: optional_action_header_block : %epsilon */case 10:/*! Production:: declaration_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$={};break;case 7:/*! Production:: optional_action_header_block : optional_action_header_block ACTION */case 8:/*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{this.$=yyvstack[yysp-1];let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` action header code block does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);}yy.addDeclaration(this.$,{actionInclude:yyvstack[yysp]});break;case 9:/*! Production:: declaration_list : declaration_list declaration */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}yy.addDeclaration(this.$,{actionInclude:yyvstack[yysp]});}break;case 9:/*! Production:: declaration_list : declaration_list declaration */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp-1];yy.addDeclaration(this.$,yyvstack[yysp]);break;case 11:/*! Production:: declaration_list : declaration_list error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) @@ -1805,19 +1805,19 @@ this.$={operator:yyvstack[yysp]};break;case 15:/*! Production:: declaration : this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$={token_list:yyvstack[yysp]};break;case 16:/*! Production:: declaration : ACTION */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` action code block does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);}this.$={include:yyvstack[yysp]};break;case 17:/*! Production:: declaration : include_macro_code */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}this.$={include:yyvstack[yysp]};}break;case 17:/*! Production:: declaration : include_macro_code */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` action header code block does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);}this.$={include:yyvstack[yysp]};break;case 18:/*! Production:: declaration : parse_params */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}this.$={include:yyvstack[yysp]};}break;case 18:/*! Production:: declaration : parse_params */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$={parseParams:yyvstack[yysp]};break;case 19:/*! Production:: declaration : parser_type */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) @@ -1851,12 +1851,12 @@ yyparser.yyError(rmCommonWS$1` ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-2])} `);break;case 27:/*! Production:: declaration : INIT_CODE init_code_name action_ne */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}this.$={initCode:{qualifier:yyvstack[yysp-1],include:yyvstack[yysp]}};break;case 28:/*! Production:: declaration : INIT_CODE error action_ne */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): + `);}this.$={initCode:{qualifier:yyvstack[yysp-1],include:yyvstack[yysp]}};}break;case 28:/*! Production:: declaration : INIT_CODE error action_ne */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself: @@ -1889,7 +1889,7 @@ yyparser.yyError(rmCommonWS$1` Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-1])} - `);break;case 32:/*! Production:: init_code_name : ID */case 33:/*! Production:: init_code_name : NAME */case 34:/*! Production:: init_code_name : STRING */case 35:/*! Production:: import_name : ID */case 36:/*! Production:: import_name : STRING */case 37:/*! Production:: import_path : ID */case 38:/*! Production:: import_path : STRING */case 67:/*! Production:: optional_token_type : TOKEN_TYPE */case 68:/*! Production:: token_value : INTEGER */case 69:/*! Production:: token_description : STRING */case 81:/*! Production:: optional_production_description : STRING */case 96:/*! Production:: expression : ID */case 102:/*! Production:: suffix : "*" */case 103:/*! Production:: suffix : "?" */case 104:/*! Production:: suffix : "+" */case 108:/*! Production:: symbol : id */case 109:/*! Production:: symbol : STRING */case 110:/*! Production:: id : ID */case 113:/*! Production:: action_ne : ACTION */case 114:/*! Production:: action_ne : include_macro_code */case 115:/*! Production:: action : action_ne */case 119:/*! Production:: action_body : action_comments_body */case 123:/*! Production:: action_comments_body : ACTION_BODY */case 125:/*! Production:: extra_parser_module_code : optional_module_code_chunk */case 129:/*! Production:: module_code_chunk : CODE */case 132:/*! Production:: optional_module_code_chunk : module_code_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);break;case 32:/*! Production:: init_code_name : ID */case 33:/*! Production:: init_code_name : NAME */case 34:/*! Production:: init_code_name : STRING */case 35:/*! Production:: import_name : ID */case 36:/*! Production:: import_name : STRING */case 37:/*! Production:: import_path : ID */case 38:/*! Production:: import_path : STRING */case 67:/*! Production:: optional_token_type : TOKEN_TYPE */case 68:/*! Production:: token_value : INTEGER */case 69:/*! Production:: token_description : STRING */case 81:/*! Production:: optional_production_description : STRING */case 96:/*! Production:: expression : ID */case 102:/*! Production:: suffix : "*" */case 103:/*! Production:: suffix : "?" */case 104:/*! Production:: suffix : "+" */case 108:/*! Production:: symbol : id */case 109:/*! Production:: symbol : STRING */case 110:/*! Production:: id : ID */case 113:/*! Production:: action_ne : ACTION */case 114:/*! Production:: action_ne : include_macro_code */case 119:/*! Production:: action_body : action_comments_body */case 123:/*! Production:: action_comments_body : ACTION_BODY */case 125:/*! Production:: extra_parser_module_code : optional_module_code_chunk */case 129:/*! Production:: module_code_chunk : CODE */case 132:/*! Production:: optional_module_code_chunk : module_code_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp];break;case 39:/*! Production:: options : OPTIONS option_list OPTIONS_END */case 111:/*! Production:: action_ne : "{" action_body "}" */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) @@ -1980,9 +1980,9 @@ this.$='right';break;case 58:/*! Production:: associativity : NONASSOC */ // this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$='nonassoc';break;case 61:/*! Production:: full_token_definitions : optional_token_type id_list */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var rv=[];var lst=yyvstack[yysp];for(var i=0,len=lst.length;i)',''),/* 66: */ /^(?:\{\{([\s\S]*?)\}\})/,/* 67: */ /^(?:%\{([\s\S]*?)%\})/,/* 68: */ /^(?:\{)/,/* 69: */ /^(?:->.*)/,/* 70: */ /^(?:→.*)/,/* 71: */ /^(?:=>.*)/,/* 72: */ /^(?:(0[Xx][\dA-Fa-f]+))/,/* 73: */ /^(?:([1-9]\d*)(?![\dA-FXa-fx]))/,/* 74: */ /^(?:[^\r\n]*(\r|\n)+)/,/* 75: */ /^(?:[^\r\n]+)/,/* 76: */ /^(?:(\r\n|\n|\r))/,/* 77: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 78: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 79: */ /^(?:([^\S\n\r])+)/,/* 80: */ /^(?:\S+)/,/* 81: */ /^(?:")/,/* 82: */ /^(?:')/,/* 83: */ /^(?:`)/,/* 84: */ /^(?:")/,/* 85: */ /^(?:')/,/* 86: */ /^(?:`)/,/* 87: */ /^(?:")/,/* 88: */ /^(?:')/,/* 89: */ /^(?:`)/,/* 90: */ /^(?:.)/,/* 91: */ /^(?:$)/],conditions:{'action':{rules:[0,1,2,3,4,5,6,7,8,81,82,83,87,88,89,90,91],inclusive:false},'code':{rules:[63,74,75,87,88,89,90,91],inclusive:false},'path':{rules:[29,30,76,77,78,79,80,87,88,89,90,91],inclusive:false},'options':{rules:[24,25,29,30,32,33,34,87,88,89,90,91],inclusive:false},'option_values':{rules:[26,27,28,29,30,31,34,84,85,86,87,88,89,90,91],inclusive:false},'token':{rules:[9,10,11,29,30,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'bnf':{rules:[12,13,14,15,16,17,18,29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'ebnf':{rules:[12,13,14,15,16,17,18,19,20,21,22,23,29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'INITIAL':{rules:[29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true}}};var rmCommonWS=helpers.rmCommonWS;var dquote=helpers.dquote;// unescape a string value which is wrapped in quotes/doublequotes -function unescQuote(str){str=''+str;var a=str.split('\\\\');a=a.map(function(s){return s.replace(/\\'/g,'\'').replace(/\\"/g,'"');});str=a.join('\\\\');return str;}lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser$2.lexer=lexer$1;var ebnf=false;var rmCommonWS$1=helpers.rmCommonWS;var dquote$1=helpers.dquote;var checkActionBlock$1=helpers.checkActionBlock;// transform ebnf to bnf if necessary + `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: \/\*[^]*?\*\/ */0:43,/*! Conditions:: action */ /*! Rule:: \/\/[^\r\n]* */1:43,/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */3:43,/*! Conditions:: action */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */4:43,/*! Conditions:: action */ /*! Rule:: [/"'][^{}/"']+ */5:43,/*! Conditions:: action */ /*! Rule:: [^{}/"']+ */6:43,/*! Conditions:: bnf ebnf */ /*! Rule:: %empty\b */13:39,/*! Conditions:: bnf ebnf */ /*! Rule:: %epsilon\b */14:39,/*! Conditions:: bnf ebnf */ /*! Rule:: Ɛ */15:39,/*! Conditions:: bnf ebnf */ /*! Rule:: ɛ */16:39,/*! Conditions:: bnf ebnf */ /*! Rule:: ε */17:39,/*! Conditions:: bnf ebnf */ /*! Rule:: ϵ */18:39,/*! Conditions:: ebnf */ /*! Rule:: \( */19:7,/*! Conditions:: ebnf */ /*! Rule:: \) */20:8,/*! Conditions:: ebnf */ /*! Rule:: \* */21:9,/*! Conditions:: ebnf */ /*! Rule:: \? */22:10,/*! Conditions:: ebnf */ /*! Rule:: \+ */23:11,/*! Conditions:: options */ /*! Rule:: {NAME} */24:25,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: {ID} */38:24,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: {NAME} */39:25,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: \$end\b */40:41,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: \$eof\b */41:41,/*! Conditions:: token */ /*! Rule:: [^\s\r\n]+ */44:'TOKEN_WORD',/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: : */45:5,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: ; */46:4,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: \| */47:6,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %debug\b */50:19,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %parser-type\b */51:32,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %prec\b */52:42,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %start\b */53:16,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %left\b */54:33,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %right\b */55:34,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %nonassoc\b */56:35,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %parse-param[s]? */58:31,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %code\b */61:23,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %import\b */62:22,/*! Conditions:: code */ /*! Rule:: [^\r\n]*(\r|\n)+ */74:46,/*! Conditions:: * */ /*! Rule:: $ */91:1},rules:[/* 0: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 1: */ /^(?:\/\/[^\r\n]*)/,/* 2: */ /^(?:\/[^ /]*?['"{}][^ ]*?\/)/,/* 3: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 4: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 5: */ /^(?:[/"'][^{}/"']+)/,/* 6: */ /^(?:[^{}/"']+)/,/* 7: */ /^(?:\{)/,/* 8: */ /^(?:\})/,/* 9: */ /^(?:(\r\n|\n|\r))/,/* 10: */ /^(?:%%)/,/* 11: */ /^(?:;)/,/* 12: */ /^(?:%%)/,/* 13: */ /^(?:%empty\b)/,/* 14: */ /^(?:%epsilon\b)/,/* 15: */ /^(?:Ɛ)/,/* 16: */ /^(?:ɛ)/,/* 17: */ /^(?:ε)/,/* 18: */ /^(?:ϵ)/,/* 19: */ /^(?:\()/,/* 20: */ /^(?:\))/,/* 21: */ /^(?:\*)/,/* 22: */ /^(?:\?)/,/* 23: */ /^(?:\+)/,/* 24: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?))',''),/* 25: */ /^(?:=)/,/* 26: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 27: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 28: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 29: */ /^(?:\/\/[^\r\n]*)/,/* 30: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 31: */ /^(?:\S+)/,/* 32: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 33: */ /^(?:(\r\n|\n|\r))/,/* 34: */ /^(?:([^\S\n\r])+)/,/* 35: */ /^(?:([^\S\n\r])+)/,/* 36: */ /^(?:(\r\n|\n|\r)+)/,/* 37: */new XRegExp__default['default']('^(?:\\[([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\])',''),/* 38: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 39: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?))',''),/* 40: */ /^(?:\$end\b)/,/* 41: */ /^(?:\$eof\b)/,/* 42: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 43: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 44: */ /^(?:\S+)/,/* 45: */ /^(?::)/,/* 46: */ /^(?:;)/,/* 47: */ /^(?:\|)/,/* 48: */ /^(?:%%)/,/* 49: */ /^(?:%ebnf\b)/,/* 50: */ /^(?:%debug\b)/,/* 51: */ /^(?:%parser-type\b)/,/* 52: */ /^(?:%prec\b)/,/* 53: */ /^(?:%start\b)/,/* 54: */ /^(?:%left\b)/,/* 55: */ /^(?:%right\b)/,/* 56: */ /^(?:%nonassoc\b)/,/* 57: */ /^(?:%token\b)/,/* 58: */ /^(?:%parse-param[s]?)/,/* 59: */ /^(?:%option[s]?)/,/* 60: */ /^(?:%lex((?:[^\S\n\r])*(?:(?:\r\n|\n|\r)[\s\S]*?)?(?:\r\n|\n|\r)(?:[^\S\n\r])*)\/lex\b)/,/* 61: */ /^(?:%code\b)/,/* 62: */ /^(?:%import\b)/,/* 63: */ /^(?:%include\b)/,/* 64: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 65: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 66: */ /^(?:\{\{([\s\S]*?)\}\})/,/* 67: */ /^(?:%\{([\s\S]*?)%\})/,/* 68: */ /^(?:\{)/,/* 69: */ /^(?:->.*)/,/* 70: */ /^(?:→.*)/,/* 71: */ /^(?:=>.*)/,/* 72: */ /^(?:(0[Xx][\dA-Fa-f]+))/,/* 73: */ /^(?:([1-9]\d*)(?![\dA-FXa-fx]))/,/* 74: */ /^(?:[^\r\n]*(\r|\n)+)/,/* 75: */ /^(?:[^\r\n]+)/,/* 76: */ /^(?:(\r\n|\n|\r))/,/* 77: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 78: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 79: */ /^(?:([^\S\n\r])+)/,/* 80: */ /^(?:\S+)/,/* 81: */ /^(?:")/,/* 82: */ /^(?:')/,/* 83: */ /^(?:`)/,/* 84: */ /^(?:")/,/* 85: */ /^(?:')/,/* 86: */ /^(?:`)/,/* 87: */ /^(?:")/,/* 88: */ /^(?:')/,/* 89: */ /^(?:`)/,/* 90: */ /^(?:.)/,/* 91: */ /^(?:$)/],conditions:{'action':{rules:[0,1,2,3,4,5,6,7,8,81,82,83,87,88,89,90,91],inclusive:false},'code':{rules:[63,74,75,87,88,89,90,91],inclusive:false},'path':{rules:[29,30,76,77,78,79,80,87,88,89,90,91],inclusive:false},'options':{rules:[24,25,29,30,32,33,34,87,88,89,90,91],inclusive:false},'option_values':{rules:[26,27,28,29,30,31,34,84,85,86,87,88,89,90,91],inclusive:false},'token':{rules:[9,10,11,29,30,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'bnf':{rules:[12,13,14,15,16,17,18,29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'ebnf':{rules:[12,13,14,15,16,17,18,19,20,21,22,23,29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'INITIAL':{rules:[29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true}}};const rmCommonWS=helpers.rmCommonWS;const dquote=helpers.dquote;// unescape a string value which is wrapped in quotes/doublequotes +function unescQuote(str){str=''+str;let a=str.split('\\\\');a=a.map(function(s){return s.replace(/\\'/g,'\'').replace(/\\"/g,'"');});str=a.join('\\\\');return str;}lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser$2.lexer=lexer$1;var ebnf=false;const rmCommonWS$1=helpers.rmCommonWS;const dquote$1=helpers.dquote;const checkActionBlock$1=helpers.checkActionBlock;const trimActionCode$1=helpers.trimActionCode;// transform ebnf to bnf if necessary function extend(json,grammar){if(ebnf){json.ebnf=grammar.grammar;// keep the original source EBNF around for possible pretty-printing & AST exports. json.bnf=transform(grammar.grammar);}else{json.bnf=grammar.grammar;}if(grammar.actionInclude){json.actionInclude=grammar.actionInclude;}return json;}// convert string value to number or boolean value, when possible // (and when this is more or less obviously the intent) // otherwise produce the string itself as value. function parseValue(v){if(v==='false'){return false;}if(v==='true'){return true;}// http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) -if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$2.warn=function p_warn(){console.warn.apply(console,arguments);};parser$2.log=function p_log(){console.log.apply(console,arguments);};function Parser$1(){this.yy={};}Parser$1.prototype=parser$2;parser$2.Parser=Parser$1;function yyparse$1(){return parser$2.parse.apply(parser$2,arguments);}var bnf={parser:parser$2,Parser:Parser$1,parse:yyparse$1};// See also: +if(v&&!isNaN(v)){let rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$2.warn=function p_warn(){console.warn.apply(console,arguments);};parser$2.log=function p_log(){console.log.apply(console,arguments);};function Parser$1(){this.yy={};}Parser$1.prototype=parser$2;parser$2.Parser=Parser$1;function yyparse$1(){return parser$2.parse.apply(parser$2,arguments);}var bnf={parser:parser$2,Parser:Parser$1,parse:yyparse$1};// See also: // http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508 // but we keep the prototype.constructor and prototype.name assignment lines too for compatibility // with userland code which might access the derived class in a 'classic' way. @@ -3522,10 +3552,10 @@ let yy=this.yy;let yyparser=yy.parser;let yylexer=yy.lexer;const OPTION_DOES_NOT this.$=yyvstack[yysp-1];this._$=yylstack[yysp-1];// END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break;case 1:/*! Production:: lex : init definitions rules_and_epilogue EOF */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];for(var key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: +{this.$=yyvstack[yysp-1];for(let key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: -for(key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){var asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: -if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +for(let key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){let asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: +if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;}case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if(yyvstack[yysp]){this.$={rules:yyvstack[yysp-1],moduleInclude:yyvstack[yysp]};}else{this.$={rules:yyvstack[yysp-1]};}break;case 3:/*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) @@ -3586,7 +3616,7 @@ yy.startConditions={};// hash table // fail. yy.__context_description__=['???CONTEXT???'];yy.pushContextDescription=function(str){yy.__context_description__.push(str);};yy.popContextDescription=function(){if(yy.__context_description__.length>1){yy.__context_description__.pop();}else{yyparser.yyError('__context_description__ stack depleted! Contact a developer!');}};yy.getContextDescription=function(){return yy.__context_description__[yy.__context_description__.length-1];};break;case 8:/*! Production:: definitions : definitions definition */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];if(yyvstack[yysp]){switch(yyvstack[yysp].type){case'macro':this.$.macros[yyvstack[yysp].name]=yyvstack[yysp].body;break;case'names':var condition_defs=yyvstack[yysp].names;for(var i=0,len=condition_defs.length;i=0){var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$2` +console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0){let marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -3897,7 +3927,7 @@ console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0 Technical error report: ${yyvstack[yysp].errStr} - `);}this.$=yyvstack[yysp-2];break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];}break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` \`${yy.__options_category_description__}\` statements must be placed in @@ -3956,14 +3986,14 @@ yyparser.yyError(rmCommonWS$2` this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 59:/*! Production:: rule : regex ACTION_START action ACTION_END */case 60:/*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);var rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` +{let srcCode=trimActionCode$2(yyvstack[yysp-1],yyvstack[yysp-2]);let rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` The lexer rule's action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION_CODE so that the action chunk test/compiler +{let srcCode=trimActionCode$2(yyvstack[yysp-1]);// 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. // @@ -3974,7 +4004,7 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION // By doing this, we simplify the token return replacement code replacement // process which will be applied to the parsed lexer before its code // will be generated by JISON. -if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}var rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` +if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}let rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` The lexer rule's 'arrow' action code section does not compile: ${rv} # NOTE that the arrow action automatically wraps the action code @@ -3983,7 +4013,7 @@ if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='retur Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` A lexer rule action arrow must be followed by a single JavaScript expression specifying the lexer token to produce, e.g.: @@ -4103,8 +4133,8 @@ yyparser.yyError(rmCommonWS$2` this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 73:/*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -this.$=yyvstack[yysp-2].map(function(el){var name=el[0];// Validate the given condition state: when it isn't known, print an error message +{// rewrite + accept star '*' as name + check if we allow empty list? +this.$=yyvstack[yysp-2].map(function(el){let name=el[0];// Validate the given condition state: when it isn't known, print an error message // accordingly: if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError(rmCommonWS$2` You specified an unknown lexer condition state '${name}'. @@ -4123,10 +4153,10 @@ if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError ${yylexer.prettyPrintRange(yylstack[yysp-2],yylstack[yysp-3],yylstack[yysp])} `);}return name;});// '<' '*' '>' // { $$ = ['*']; } -break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): +}break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$2` +{// rewrite + accept star '*' as name + check if we allow empty list? +let lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$2` Seems you did not correctly terminate the start condition set <${lst.join(',')},???> with a terminating '>' @@ -4136,9 +4166,9 @@ var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCom Technical error report: ${yyvstack[yysp].errStr} - `);break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// Detect if the regex ends with a pure (Unicode) word; +{// Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are // all valid 'words' for the 'easy keyword rules' option: @@ -4176,7 +4206,7 @@ this.$=this.$.replace(/\\\\/g,'.').replace(/"/g,'.').replace(/\\c[A-Z]/g,'.').re this.$=JSON.parse('"'+this.$+'"');}catch(ex){yyparser.warn('easy-keyword-rule FAIL on eval: ',ex);// make the next keyword test fail: this.$='.';}// a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: -var re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +let re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp];break;case 78:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) @@ -4238,17 +4268,17 @@ if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/ this.$=yyvstack[yysp];}else{this.$=yyvstack[yysp];}//yyparser.log("name expansion for: ", { name: $name_expansion, redux: $name_expansion.replace(/[{}]/g, ''), output: $$ }); break;case 111:/*! Production:: literal_string : STRING_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var src=yyvstack[yysp];var s=src.substring(1,src.length-1);var edge=src[0];this.$=encodeRegexLiteralStr(s,edge);break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +{let src=yyvstack[yysp];let s=src.substring(1,src.length-1);let edge=src[0];this.$=encodeRegexLiteralStr(s,edge);}break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +{let s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);}break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal behaviour under the given circumstances, i.e. parser context: +{// validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$2` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp]),yylstack[yysp-4])} - `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){var optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$2` + `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){let optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$2` You may not separate entries in a ${yy.__options_category_description__} statement using commas. Use whitespace instead, e.g.: @@ -4256,7 +4286,7 @@ if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyErro Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);}break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$2` @@ -4289,7 +4319,7 @@ yyparser.yyError(rmCommonWS$2` ${yyvstack[yysp].errStr} `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) -var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` +{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. Erroneous area: @@ -4297,14 +4327,14 @@ var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&O Technical error report: ${yyvstack[yysp].errStr} - `);break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: +{// validate that this is legal input under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES){this.$=mkIdentifier$1(yyvstack[yysp]);// check if the transformation is obvious & trivial to humans; // if not, report an error as we don't want confusion due to // typos and/or garbage input here producing something that // is usable from a machine perspective. -if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` +if(!isLegalIdentifierInput$1(yyvstack[yysp])){let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -4312,10 +4342,10 @@ if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optiona Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}}else{this.$=yyvstack[yysp];}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}else{this.$=yyvstack[yysp];}}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: -if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` +{// validate that this is legal input under the given circumstances, i.e. parser context: +if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -4323,7 +4353,7 @@ if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_fl Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=JSON5__default['default'].parse(yyvstack[yysp]);break;case 123:/*! Production:: option_value : OPTION_VALUE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) @@ -4331,12 +4361,12 @@ this.$=parseValue$1(yyvstack[yysp]);break;case 124:/*! Production:: epilogue this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 125:/*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){var rv=checkActionBlock$2(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$2` +{let srcCode=trimActionCode$2(yyvstack[yysp]);if(srcCode){let rv=checkActionBlock$2(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$2` The '%%' lexer epilogue code does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-1])} - `);}}this.$=srcCode;break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$=srcCode;}break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` There's an error in your lexer epilogue code block. @@ -4359,7 +4389,7 @@ yyparser.yyError(rmCommonWS$2` ${yyvstack[yysp].errStr} `);this.$='';break;case 130:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` +{let srcCode=trimActionCode$2(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){let rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} Erroneous area: @@ -4367,9 +4397,9 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var `);}}// Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) // we append those protective double newlines right now, as the calling site // won't do it for us: -this.$='\n\n'+srcCode+'\n\n';break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): +this.$='\n\n'+srcCode+'\n\n';}break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$2` +{let start_marker=yyvstack[yysp-1].trim();yyparser.yyError(rmCommonWS$2` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -4377,14 +4407,14 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$='';break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);this.$='';}break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // these code chunks are very probably incomplete, hence compile-testing // for these should be deferred until we've collected the entire epilogue. this.$=yyvstack[yysp];break;case 134:/*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) -// check if there is only 1 unvalued options: 'path' -var lst=yyvstack[yysp-1];var len=lst.length;var path;if(len===1&&lst[0][1]===true){// `path`: +{// check if there is only 1 unvalued options: 'path' +let lst=yyvstack[yysp-1];let len=lst.length;let path;if(len===1&&lst[0][1]===true){// `path`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$2` You did not specify a legal file path for the '%include' statement, which must have the format: %include file_path @@ -4404,12 +4434,12 @@ path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$2` Technical error report: ${$error.errStr} `);}// **Aside**: And no, we don't support nested '%include'! -var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var srcCode=trimActionCode$1(fileContent);if(srcCode){var rv=checkActionBlock$2(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$2` +let fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});let srcCode=trimActionCode$2(fileContent);if(srcCode){let rv=checkActionBlock$2(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$2` The source code included from file '${path}' does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(this._$)} - `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';}break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` %include MUST be followed by a valid file path. @@ -5583,8 +5613,8 @@ yy_.yyerror(rmCommonWS` return 35;case 5:/*! Conditions:: action */ /*! Rule:: \/\/.* */yy.include_command_allowed=false;return 35;case 6:/*! Conditions:: action */ /*! Rule:: \| */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 7:/*! Conditions:: action */ /*! Rule:: %% */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 8:/*! Conditions:: action */ /*! Rule:: \/(?=\s) */return 35;// most probably a `/` divide operator. -case 9:/*! Conditions:: action */ /*! Rule:: \/.* */yy.include_command_allowed=false;var l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: -this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` +case 9:/*! Conditions:: action */ /*! Rule:: \/.* */{yy.include_command_allowed=false;let l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: +this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;}case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` too many closing curly braces in lexer rule action block. Note: the action code chunk may be too complex for jison to parse @@ -5604,16 +5634,16 @@ return 23;}case 18:/*! Conditions:: action */ /*! Rule:: $ */yy.include_co to help jison grok more or less complex action code chunks. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */{yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). -var marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: +let marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own, i.e. is not a rule action, %code // section, etc... -//var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); -//var precedingStr = this.matched.substr(-this.match.length - 1, 1); -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? -var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: +//let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); +//let precedingStr = this.matched.substr(-this.match.length - 1, 1); +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? +let endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: // we'd better make sure that end marker indeed does exist in the // remainder of the input! When it's not, we'll have the `action` // lexer state running past its due date as it'll then go and spit @@ -5623,7 +5653,7 @@ var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity c // Writing the wrong end marker is a common user mistake, we can // easily look ahead and check for it now and report a proper hint // to cover this failure mode in a more helpful manner. -var remaining=this.lookAhead();var prevEnd=0;var endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, +let remaining=this.lookAhead();let prevEnd=0;let endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd=endMarkerIndex+endMarker.length;continue;}if(endMarkerIndex<0){yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the @@ -5634,7 +5664,7 @@ if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd= `+this.prettyPrintRange(yy_.yylloc));return 24;}break;}// Allow the start marker to be re-matched by the generated lexer rule regex: this.unput(marker);// Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: yy_.yytext=marker;// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); +if(atSOL){return 22;}return 25;}case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */{yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); this.pushState('action');// Do a bit of magic that's useful for the parser when we // call `trimActionCode()` in there to perform a bit of // rough initial action code chunk cleanup: @@ -5659,27 +5689,27 @@ this.pushState('action');// Do a bit of magic that's useful for the parser when // follow after `trimActionCode()` has passed once we // get to the parser productions which process this // upcoming action code block. -var la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser -}return 25;case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse +let la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser +}return 25;}case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);return 25;case 32:/*! Conditions:: options */ /*! Rule:: > */this.popState();this.unput(yy_.yytext);return 21;case 35:/*! Conditions:: options */ /*! Rule:: <{ID}> */yy_.yytext=this.matches[1];return'TOKEN_TYPE';case 37:/*! Conditions:: options */ /*! Rule:: {BR}{WS}+(?=\S) */ /* ignore */break;case 38:/*! Conditions:: options */ /*! Rule:: {BR} */this.popState();this.unput(yy_.yytext);return 21;case 39:/*! Conditions:: options */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 40:/*! Conditions:: INITIAL */ /*! Rule:: {ID} */this.pushState('macro');return 19;case 41:/*! Conditions:: macro */ /*! Rule:: {BR}+ */this.popState();this.unput(yy_.yytext);return 20;case 42:/*! Conditions:: macro */ /*! Rule:: $ */this.popState();this.unput(yy_.yytext);return 20;case 43:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {BR}+ */ /* skip newlines */break;case 44:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 48:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {ANY_LITERAL_CHAR}+ */ // accept any non-regex, non-lex, non-string-delim, // non-escape-starter, non-space character as-is return 50;case 49:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \[ */this.pushState('set');return 45;case 64:/*! Conditions:: rules macro INITIAL */ /*! Rule:: < */this.pushState('options');return 3;case 66:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/! */return 41;// treated as `(?!atom)` case 67:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/ */return 13;// treated as `(?=atom)` -case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */var m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A -var v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 -var v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A -var v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[5],16);yy_.yytext=v;}return 43;case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: +case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */{let m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A +let v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 +let v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A +let v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[5],16);yy_.yytext=v;}return 43;}case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */{yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own. -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` +if(atSOL){return 22;}return 25;}case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` ignoring unsupported lexer option ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -5712,22 +5742,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` unterminated string constant in %options entry. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 101:/*! Conditions:: * */ /*! Rule:: ' */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 101:/*! Conditions:: * */ /*! Rule:: ' */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 102:/*! Conditions:: * */ /*! Rule:: ` */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 102:/*! Conditions:: * */ /*! Rule:: ` */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 103:/*! Conditions:: macro rules */ /*! Rule:: . */ /* b0rk on bad characters */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 103:/*! Conditions:: macro rules */ /*! Rule:: . */{/* b0rk on bad characters */let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -5739,7 +5769,7 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` regex expression here in jison-lex ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 2;}case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` unsupported lexer input: ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -5753,22 +5783,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` while lexing in ${dquote(this.topState())} state. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};var rmCommonWS=helpers.rmCommonWS;var dquote=helpers.dquote;var scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a + `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};const rmCommonWS=helpers.rmCommonWS;const dquote=helpers.dquote;const scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a // lexer rule to match when the need arrises: lexer.setupDelimitedActionChunkLexerRegex=function lexer__setupDelimitedActionChunkLexerRegex(marker){// Special: when we encounter `{` as the start of the action code block, // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! -var doNotPatch=marker==='{';var action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! +let doNotPatch=marker==='{';let action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! // // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) -var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. +let spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps // speed up those activities a tiny bit. -spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regexes;var len=spec.__rule_count;var rules=spec.rules;var i;var action_chunk_regex;// Must we still locate the rule to patch or have we done +spec=this.__currentRuleSet__=this._currentRules();}let regexes=spec.__rule_regexes;let len=spec.__rule_count;let rules=spec.rules;let i;let action_chunk_regex;// Must we still locate the rule to patch or have we done // that already during a previous encounter? // // WARNING: our cache/patch must live beyond the current lexer+parser invocation: @@ -5781,10 +5811,10 @@ spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regex if(!spec.__action_chunk_rule_idx){// **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! -var orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';var orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. +let orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';let orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! -for(i=1;i<=len;i++){var rule_re=regexes[i];var re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); +for(i=1;i<=len;i++){let rule_re=regexes[i];let re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if(re_str===orig_re_str1||re_str===orig_re_str2){spec.__action_chunk_rule_idx=i;break;}}if(!spec.__action_chunk_rule_idx){//console.error('ruleset dump:', spec); throw new Error('INTERNAL DEV ERROR: cannot locate %{...%} rule regex!');}// As we haven't initialized yet, we're sure the rule cache doesn't exist either. // Make it happen: @@ -5794,7 +5824,7 @@ spec.__cached_action_chunk_rule={};// set up empty cache action_chunk_regex=spec.__cached_action_chunk_rule[marker];if(!action_chunk_regex){action_chunk_regex=spec.__cached_action_chunk_rule[marker]=new RegExp('^(?:'+marker.replace(/\{/g,'\\{')+'([^]*?)'+action_end_marker.replace(/\}/g,'\\}')+'(?!\\}))');//console.warn('encode new action block regex:', action_chunk_regex); }//console.error('new ACTION REGEX:', { i, action_chunk_regex }); // and patch the lexer regex table for the current lexer condition state: -regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser$3.lexer=lexer$2;var rmCommonWS$2=helpers.rmCommonWS;var checkActionBlock$2=helpers.checkActionBlock;var mkIdentifier$1=helpers.mkIdentifier;var isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;var trimActionCode$1=helpers.trimActionCode;// see also: +regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser$3.lexer=lexer$2;const rmCommonWS$2=helpers.rmCommonWS;const checkActionBlock$2=helpers.checkActionBlock;const mkIdentifier$1=helpers.mkIdentifier;const isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;const trimActionCode$2=helpers.trimActionCode;// see also: // - https://en.wikipedia.org/wiki/C0_and_C1_control_codes // - https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-escapes-in-regular-expressions // - https://kangax.github.io/compat-table/es6/#test-RegExp_y_and_u_flags @@ -5806,27 +5836,27 @@ const charCvtTable={// "\a": "\x07", "\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v"};const escCvtTable={"a":"\\x07","e":"\\x1B","b":"\\x08","f":"\\f","n":"\\n","r":"\\r","t":"\\t","v":"\\v"};const codeCvtTable={12:"\\f",10:"\\n",13:"\\r",9:"\\t",11:"\\v"};// Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){var rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); -for(var i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead +const codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){let rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); +for(let i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. -var m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s +let m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s rv+='\\\\'+m[1];i+=m[1].length-1;continue;}if(m[2]){// [2]: regex special characters, which occur in a literal string: `\[` --> \\\[ rv+='\\\\\\'+m[2];i+=m[2].length-1;continue;}if(m[3]){// [3]: special escape characters, which occur in a literal string: `\a` --> BELL rv+=escCvtTable[m[3]];i+=m[3].length-1;continue;}if(m[4]){// [4]: octal char: `\012` --> \x0A -var v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 -var v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A -var v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: +let v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 +let v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A +let v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: rv+='\\\\';i--;continue;default:// escape regex operators: -var pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}var cc=charCvtTable[c];if(cc){rv+=cc;continue;}var cc=c.charCodeAt(0);if(cc<32){var rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); +let pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}let cc=charCvtTable[c];if(cc){rv+=cc;continue;}cc=c.charCodeAt(0);if(cc<32){let rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); return s;}// convert string value to number or boolean value, when possible // (and when this is more or less obviously the intent) // otherwise produce the string itself as value. function parseValue$1(v){if(v==='false'){return false;}if(v==='true'){return true;}// http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) -if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$3.warn=function p_warn(){console.warn.apply(console,arguments);};parser$3.log=function p_log(){console.log.apply(console,arguments);};parser$3.pre_parse=function p_lex(){if(parser$3.yydebug)parser$3.log('pre_parse:',arguments);};parser$3.yy.pre_parse=function p_lex(){if(parser$3.yydebug)parser$3.log('pre_parse YY:',arguments);};parser$3.yy.post_lex=function p_lex(){if(parser$3.yydebug)parser$3.log('post_lex:',arguments);};function Parser$2(){this.yy={};}Parser$2.prototype=parser$3;parser$3.Parser=Parser$2;function yyparse$2(){return parser$3.parse.apply(parser$3,arguments);}var jisonlex={parser:parser$3,Parser:Parser$2,parse:yyparse$2};const version='0.6.2-220';// require('./package.json').version; +if(v&&!isNaN(v)){let rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$3.warn=function p_warn(){console.warn.apply(console,arguments);};parser$3.log=function p_log(){console.log.apply(console,arguments);};parser$3.pre_parse=function p_lex(){if(parser$3.yydebug)parser$3.log('pre_parse:',arguments);};parser$3.yy.pre_parse=function p_lex(){if(parser$3.yydebug)parser$3.log('pre_parse YY:',arguments);};parser$3.yy.post_lex=function p_lex(){if(parser$3.yydebug)parser$3.log('post_lex:',arguments);};function Parser$2(){this.yy={};}Parser$2.prototype=parser$3;parser$3.Parser=Parser$2;function yyparse$2(){return parser$3.parse.apply(parser$3,arguments);}var jisonlex={parser:parser$3,Parser:Parser$2,parse:yyparse$2};const version='0.6.2-220';// require('./package.json').version; function parse(grammar){return bnf.parser.parse(grammar);}// adds a declaration to the grammar bnf.parser.yy.addDeclaration=function bnfAddDeclaration(grammar,decl){if(!decl){return;}if(decl.start){grammar.start=decl.start;}if(decl.lex){grammar.lex=parseLex(decl.lex.text,decl.lex.position);}if(decl.grammar){grammar.grammar=decl.grammar;}if(decl.ebnf){grammar.ebnf=decl.ebnf;}if(decl.bnf){grammar.bnf=decl.bnf;}if(decl.operator){if(!grammar.operators)grammar.operators=[];grammar.operators.push(decl.operator);}if(decl.token){if(!grammar.extra_tokens)grammar.extra_tokens=[];grammar.extra_tokens.push(decl.token);}if(decl.token_list){if(!grammar.extra_tokens)grammar.extra_tokens=[];decl.token_list.forEach(function(tok){grammar.extra_tokens.push(tok);});}if(decl.parseParams){if(!grammar.parseParams)grammar.parseParams=[];grammar.parseParams=grammar.parseParams.concat(decl.parseParams);}if(decl.parserType){if(!grammar.options)grammar.options={};grammar.options.type=decl.parserType;}if(decl.include){if(!grammar.moduleInclude){grammar.moduleInclude=decl.include;}else{grammar.moduleInclude+='\n\n'+decl.include;}}if(decl.actionInclude){if(!grammar.actionInclude){grammar.actionInclude=decl.actionInclude;}else{grammar.actionInclude+='\n\n'+decl.actionInclude;}}if(decl.options){if(!grammar.options)grammar.options={};// last occurrence of `%options` wins: for(let i=0;i= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -15350,6 +15457,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -15515,8 +15623,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The lexer rule's action code section does not compile: ${rv} @@ -15526,6 +15635,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -15536,7 +15646,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1]); // 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. @@ -15554,7 +15665,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -15569,6 +15680,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -15814,9 +15926,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -15844,6 +15957,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -15855,8 +15969,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -15871,6 +15986,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -15881,6 +15997,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -15935,13 +16052,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -16229,10 +16347,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -16243,8 +16363,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -16255,6 +16377,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$2` @@ -16265,7 +16388,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -16282,6 +16405,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -16377,7 +16501,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -16390,6 +16515,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -16400,6 +16526,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -16408,7 +16535,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -16425,6 +16552,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -16435,11 +16563,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -16453,6 +16582,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -16496,9 +16626,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$2(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$2(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The '%%' lexer epilogue code does not compile: ${rv} @@ -16509,6 +16640,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -16560,9 +16692,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -16576,6 +16709,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -16586,8 +16720,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$2` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -16598,6 +16732,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -16621,10 +16756,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -16653,11 +16789,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$2(fileContent); if (srcCode) { - var rv = checkActionBlock$2(srcCode, this._$, yy); + let rv = checkActionBlock$2(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$2` The source code included from file '${path}' does not compile: ${rv} @@ -16669,6 +16805,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -21818,21 +21955,22 @@ var lexer$2 = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -21926,55 +22064,55 @@ var lexer$2 = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -21982,24 +22120,25 @@ var lexer$2 = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -22027,44 +22166,45 @@ var lexer$2 = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -22189,38 +22329,39 @@ var lexer$2 = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -22260,29 +22401,30 @@ var lexer$2 = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -22386,49 +22528,56 @@ var lexer$2 = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -22442,7 +22591,8 @@ var lexer$2 = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -23019,9 +23169,9 @@ var lexer$2 = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -23030,9 +23180,9 @@ var lexer$2 = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -23040,7 +23190,7 @@ var lexer$2 = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -23050,11 +23200,11 @@ var lexer$2 = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -23070,15 +23220,15 @@ var lexer$2 = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -23138,11 +23288,11 @@ var lexer$2 = function() { }(); parser$3.lexer = lexer$2; -var rmCommonWS$2 = helpers.rmCommonWS; -var checkActionBlock$2 = helpers.checkActionBlock; -var mkIdentifier$1 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$2 = helpers.rmCommonWS; +const checkActionBlock$2 = helpers.checkActionBlock; +const mkIdentifier$1 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$2 = helpers.trimActionCode; // see also: @@ -23183,11 +23333,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -23197,7 +23347,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -23206,10 +23356,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -23219,7 +23369,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -23232,7 +23382,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -23254,35 +23404,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -23296,19 +23446,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -23339,7 +23489,7 @@ function parseValue$1(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/ebnf-parser/dist/ebnf-parser-es6.js b/packages/ebnf-parser/dist/ebnf-parser-es6.js index 7cfd562ef..7d7f5c845 100644 --- a/packages/ebnf-parser/dist/ebnf-parser-es6.js +++ b/packages/ebnf-parser/dist/ebnf-parser-es6.js @@ -6431,8 +6431,6 @@ case 4: /*! Production:: optional_end_block : %epsilon */ case 101: /*! Production:: suffix : %epsilon */ -case 117: - /*! Production:: action : %epsilon */ case 118: /*! Production:: action_body : %epsilon */ case 133: @@ -6454,7 +6452,8 @@ case 5: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$1` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} @@ -6464,6 +6463,7 @@ case 5: `); } this.$ = yyvstack[yysp]; + } break; case 6: @@ -6489,8 +6489,9 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$1` action header code block does not compile: ${rv} @@ -6500,6 +6501,7 @@ case 8: `); } yy.addDeclaration(this.$, { actionInclude: yyvstack[yysp] }); + } break; case 9: @@ -6583,7 +6585,8 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$1` action code block does not compile: ${rv} @@ -6593,6 +6596,7 @@ case 16: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 17: @@ -6603,7 +6607,8 @@ case 17: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$1` action header code block does not compile: ${rv} @@ -6613,6 +6618,7 @@ case 17: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 18: @@ -6739,7 +6745,8 @@ case 27: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS$1` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} @@ -6754,6 +6761,7 @@ case 27: include: yyvstack[yysp] } }; + } break; case 28: @@ -6869,8 +6877,6 @@ case 113: /*! Production:: action_ne : ACTION */ case 114: /*! Production:: action_ne : include_macro_code */ -case 115: - /*! Production:: action : action_ne */ case 119: /*! Production:: action_body : action_comments_body */ case 123: @@ -7170,17 +7176,19 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = {id: id}; + { + let rv = []; + let lst = yyvstack[yysp]; + for (let i = 0, len = lst.length; i < len; i++) { + let id = lst[i]; + let m = {id: id}; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } rv.push(m); } this.$ = rv; + } break; case 62: @@ -7191,11 +7199,13 @@ case 62: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + let m = yyvstack[yysp]; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } this.$ = [m]; + } break; case 63: @@ -7473,18 +7483,37 @@ case 87: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { this.$ = [(yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '')]; if (yyvstack[yysp]) { - var rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$1(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$1` - production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$1` + production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } else { + let indentedSrc = rmCommonWS$1([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$1` + production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { @@ -7500,6 +7529,7 @@ case 87: if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 88: @@ -7510,22 +7540,42 @@ case 88: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = ['']; if (yyvstack[yysp]) { - var rv = checkActionBlock$1(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock$1(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$1` - epsilon production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS$1` + epsilon production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } else { + let indentedSrc = rmCommonWS$1([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS$1` + epsilon production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 89: @@ -7706,6 +7756,8 @@ case 106: case 107: /*! Production:: prec : %epsilon */ +case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); @@ -7732,6 +7784,20 @@ case 112: `); break; +case 115: + /*! Production:: action : action_ne */ + + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; + break; + case 116: /*! Production:: action : ARROW_ACTION */ @@ -7740,7 +7806,17 @@ case 116: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + let src = trimActionCode$1(yyvstack[yysp]); + this.$ = { + action: ` + this.$ = ( + ${src} + ); + `, + isArrowAction: true + }; + } break; case 120: @@ -7801,8 +7877,9 @@ case 127: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs.readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); - var rv = checkActionBlock$1(fileContent); + { + let fileContent = fs.readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); + let rv = checkActionBlock$1(fileContent); if (rv) { yyparser.yyError(rmCommonWS$1` included action code file "${$PATH}" does not compile: ${rv} @@ -7813,6 +7890,7 @@ case 127: } // And no, we don't support nested '%include': this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -13028,42 +13106,48 @@ var lexer$1 = function() { case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } case 90: /*! Conditions:: * */ /*! Rule:: . */ @@ -13597,13 +13681,13 @@ var lexer$1 = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; // unescape a string value which is wrapped in quotes/doublequotes function unescQuote(str) { str = '' + str; - var a = str.split('\\\\'); + let a = str.split('\\\\'); a = a.map(function(s) { return s.replace(/\\'/g, '\'').replace(/\\"/g, '"'); @@ -13639,9 +13723,10 @@ var ebnf = false; -var rmCommonWS$1 = helpers.rmCommonWS; -var dquote$1 = helpers.dquote; -var checkActionBlock$1 = helpers.checkActionBlock; +const rmCommonWS$1 = helpers.rmCommonWS; +const dquote$1 = helpers.dquote; +const checkActionBlock$1 = helpers.checkActionBlock; +const trimActionCode$1 = helpers.trimActionCode; // transform ebnf to bnf if necessary @@ -13672,7 +13757,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -14370,20 +14455,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -14393,6 +14479,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -14542,6 +14629,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -14550,9 +14638,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$2` You have specified the lexer condition state '${name}' as both @@ -14599,6 +14687,7 @@ case 8: break; } } + } break; case 9: @@ -14683,8 +14772,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -14692,6 +14782,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -14722,8 +14813,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -14731,6 +14823,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -14761,9 +14854,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -14775,6 +14869,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -14800,8 +14895,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$2` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -14822,8 +14915,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -14838,6 +14932,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -14848,11 +14943,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -14897,10 +14994,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -14929,6 +15027,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -14962,10 +15061,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -14987,8 +15087,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$2(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The '%code ${name}' initialization code section does not compile: ${rv} @@ -15004,6 +15104,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -15015,9 +15116,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$2` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -15031,6 +15133,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -15243,9 +15346,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -15257,6 +15361,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -15280,8 +15385,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$2` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -15292,6 +15397,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -15302,13 +15408,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -15338,6 +15445,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -15503,8 +15611,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The lexer rule's action code section does not compile: ${rv} @@ -15514,6 +15623,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -15524,7 +15634,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1]); // 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. @@ -15542,7 +15653,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -15557,6 +15668,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -15802,9 +15914,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -15832,6 +15945,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -15843,8 +15957,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -15859,6 +15974,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -15869,6 +15985,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -15923,13 +16040,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp('\\w[\\w\\d]*$'); + let re = new XRegExp('\\w[\\w\\d]*$'); if (XRegExp.match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -16217,10 +16335,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -16231,8 +16351,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -16243,6 +16365,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$2` @@ -16253,7 +16376,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -16270,6 +16393,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -16365,7 +16489,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -16378,6 +16503,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -16388,6 +16514,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -16396,7 +16523,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -16413,6 +16540,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -16423,11 +16551,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -16441,6 +16570,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -16484,9 +16614,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$2(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$2(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The '%%' lexer epilogue code does not compile: ${rv} @@ -16497,6 +16628,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -16548,9 +16680,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -16564,6 +16697,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -16574,8 +16708,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$2` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -16586,6 +16720,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -16609,10 +16744,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -16641,11 +16777,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$2(fileContent); if (srcCode) { - var rv = checkActionBlock$2(srcCode, this._$, yy); + let rv = checkActionBlock$2(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$2` The source code included from file '${path}' does not compile: ${rv} @@ -16657,6 +16793,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -21806,21 +21943,22 @@ var lexer$2 = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -21914,55 +22052,55 @@ var lexer$2 = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -21970,24 +22108,25 @@ var lexer$2 = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -22015,44 +22154,45 @@ var lexer$2 = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -22177,38 +22317,39 @@ var lexer$2 = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -22248,29 +22389,30 @@ var lexer$2 = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -22374,49 +22516,56 @@ var lexer$2 = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -22430,7 +22579,8 @@ var lexer$2 = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -23007,9 +23157,9 @@ var lexer$2 = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -23018,9 +23168,9 @@ var lexer$2 = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -23028,7 +23178,7 @@ var lexer$2 = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -23038,11 +23188,11 @@ var lexer$2 = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -23058,15 +23208,15 @@ var lexer$2 = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -23126,11 +23276,11 @@ var lexer$2 = function() { }(); parser$3.lexer = lexer$2; -var rmCommonWS$2 = helpers.rmCommonWS; -var checkActionBlock$2 = helpers.checkActionBlock; -var mkIdentifier$1 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$2 = helpers.rmCommonWS; +const checkActionBlock$2 = helpers.checkActionBlock; +const mkIdentifier$1 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$2 = helpers.trimActionCode; // see also: @@ -23171,11 +23321,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -23185,7 +23335,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -23194,10 +23344,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -23207,7 +23357,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -23220,7 +23370,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -23242,35 +23392,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -23284,19 +23434,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -23327,7 +23477,7 @@ function parseValue$1(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/ebnf-parser/dist/ebnf-parser-umd-es5.js b/packages/ebnf-parser/dist/ebnf-parser-umd-es5.js index efd032a67..a3ba84c05 100644 --- a/packages/ebnf-parser/dist/ebnf-parser-umd-es5.js +++ b/packages/ebnf-parser/dist/ebnf-parser-umd-es5.js @@ -1767,25 +1767,25 @@ yyparser.yyError(rmCommonWS$1` Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-2])} - `);break;case 4:/*! Production:: optional_end_block : %epsilon */case 101:/*! Production:: suffix : %epsilon */case 117:/*! Production:: action : %epsilon */case 118:/*! Production:: action_body : %epsilon */case 133:/*! Production:: optional_module_code_chunk : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): + `);break;case 4:/*! Production:: optional_end_block : %epsilon */case 101:/*! Production:: suffix : %epsilon */case 118:/*! Production:: action_body : %epsilon */case 133:/*! Production:: optional_module_code_chunk : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 5:/*! Production:: optional_end_block : "%%" extra_parser_module_code */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);}this.$=yyvstack[yysp];break;case 6:/*! Production:: optional_action_header_block : %epsilon */case 10:/*! Production:: declaration_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp];}break;case 6:/*! Production:: optional_action_header_block : %epsilon */case 10:/*! Production:: declaration_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$={};break;case 7:/*! Production:: optional_action_header_block : optional_action_header_block ACTION */case 8:/*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{this.$=yyvstack[yysp-1];let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` action header code block does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);}yy.addDeclaration(this.$,{actionInclude:yyvstack[yysp]});break;case 9:/*! Production:: declaration_list : declaration_list declaration */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}yy.addDeclaration(this.$,{actionInclude:yyvstack[yysp]});}break;case 9:/*! Production:: declaration_list : declaration_list declaration */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp-1];yy.addDeclaration(this.$,yyvstack[yysp]);break;case 11:/*! Production:: declaration_list : declaration_list error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) @@ -1805,19 +1805,19 @@ this.$={operator:yyvstack[yysp]};break;case 15:/*! Production:: declaration : this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$={token_list:yyvstack[yysp]};break;case 16:/*! Production:: declaration : ACTION */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` action code block does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);}this.$={include:yyvstack[yysp]};break;case 17:/*! Production:: declaration : include_macro_code */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}this.$={include:yyvstack[yysp]};}break;case 17:/*! Production:: declaration : include_macro_code */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` action header code block does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);}this.$={include:yyvstack[yysp]};break;case 18:/*! Production:: declaration : parse_params */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}this.$={include:yyvstack[yysp]};}break;case 18:/*! Production:: declaration : parse_params */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$={parseParams:yyvstack[yysp]};break;case 19:/*! Production:: declaration : parser_type */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) @@ -1851,12 +1851,12 @@ yyparser.yyError(rmCommonWS$1` ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-2])} `);break;case 27:/*! Production:: declaration : INIT_CODE init_code_name action_ne */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -var rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` +{let rv=checkActionBlock$1(yyvstack[yysp],yylstack[yysp]);if(rv){yyparser.yyError(rmCommonWS$1` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}this.$={initCode:{qualifier:yyvstack[yysp-1],include:yyvstack[yysp]}};break;case 28:/*! Production:: declaration : INIT_CODE error action_ne */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): + `);}this.$={initCode:{qualifier:yyvstack[yysp-1],include:yyvstack[yysp]}};}break;case 28:/*! Production:: declaration : INIT_CODE error action_ne */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself: @@ -1889,7 +1889,7 @@ yyparser.yyError(rmCommonWS$1` Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-1])} - `);break;case 32:/*! Production:: init_code_name : ID */case 33:/*! Production:: init_code_name : NAME */case 34:/*! Production:: init_code_name : STRING */case 35:/*! Production:: import_name : ID */case 36:/*! Production:: import_name : STRING */case 37:/*! Production:: import_path : ID */case 38:/*! Production:: import_path : STRING */case 67:/*! Production:: optional_token_type : TOKEN_TYPE */case 68:/*! Production:: token_value : INTEGER */case 69:/*! Production:: token_description : STRING */case 81:/*! Production:: optional_production_description : STRING */case 96:/*! Production:: expression : ID */case 102:/*! Production:: suffix : "*" */case 103:/*! Production:: suffix : "?" */case 104:/*! Production:: suffix : "+" */case 108:/*! Production:: symbol : id */case 109:/*! Production:: symbol : STRING */case 110:/*! Production:: id : ID */case 113:/*! Production:: action_ne : ACTION */case 114:/*! Production:: action_ne : include_macro_code */case 115:/*! Production:: action : action_ne */case 119:/*! Production:: action_body : action_comments_body */case 123:/*! Production:: action_comments_body : ACTION_BODY */case 125:/*! Production:: extra_parser_module_code : optional_module_code_chunk */case 129:/*! Production:: module_code_chunk : CODE */case 132:/*! Production:: optional_module_code_chunk : module_code_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);break;case 32:/*! Production:: init_code_name : ID */case 33:/*! Production:: init_code_name : NAME */case 34:/*! Production:: init_code_name : STRING */case 35:/*! Production:: import_name : ID */case 36:/*! Production:: import_name : STRING */case 37:/*! Production:: import_path : ID */case 38:/*! Production:: import_path : STRING */case 67:/*! Production:: optional_token_type : TOKEN_TYPE */case 68:/*! Production:: token_value : INTEGER */case 69:/*! Production:: token_description : STRING */case 81:/*! Production:: optional_production_description : STRING */case 96:/*! Production:: expression : ID */case 102:/*! Production:: suffix : "*" */case 103:/*! Production:: suffix : "?" */case 104:/*! Production:: suffix : "+" */case 108:/*! Production:: symbol : id */case 109:/*! Production:: symbol : STRING */case 110:/*! Production:: id : ID */case 113:/*! Production:: action_ne : ACTION */case 114:/*! Production:: action_ne : include_macro_code */case 119:/*! Production:: action_body : action_comments_body */case 123:/*! Production:: action_comments_body : ACTION_BODY */case 125:/*! Production:: extra_parser_module_code : optional_module_code_chunk */case 129:/*! Production:: module_code_chunk : CODE */case 132:/*! Production:: optional_module_code_chunk : module_code_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp];break;case 39:/*! Production:: options : OPTIONS option_list OPTIONS_END */case 111:/*! Production:: action_ne : "{" action_body "}" */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) @@ -1980,9 +1980,9 @@ this.$='right';break;case 58:/*! Production:: associativity : NONASSOC */ // this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$='nonassoc';break;case 61:/*! Production:: full_token_definitions : optional_token_type id_list */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var rv=[];var lst=yyvstack[yysp];for(var i=0,len=lst.length;i)',''),/* 66: */ /^(?:\{\{([\s\S]*?)\}\})/,/* 67: */ /^(?:%\{([\s\S]*?)%\})/,/* 68: */ /^(?:\{)/,/* 69: */ /^(?:->.*)/,/* 70: */ /^(?:→.*)/,/* 71: */ /^(?:=>.*)/,/* 72: */ /^(?:(0[Xx][\dA-Fa-f]+))/,/* 73: */ /^(?:([1-9]\d*)(?![\dA-FXa-fx]))/,/* 74: */ /^(?:[^\r\n]*(\r|\n)+)/,/* 75: */ /^(?:[^\r\n]+)/,/* 76: */ /^(?:(\r\n|\n|\r))/,/* 77: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 78: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 79: */ /^(?:([^\S\n\r])+)/,/* 80: */ /^(?:\S+)/,/* 81: */ /^(?:")/,/* 82: */ /^(?:')/,/* 83: */ /^(?:`)/,/* 84: */ /^(?:")/,/* 85: */ /^(?:')/,/* 86: */ /^(?:`)/,/* 87: */ /^(?:")/,/* 88: */ /^(?:')/,/* 89: */ /^(?:`)/,/* 90: */ /^(?:.)/,/* 91: */ /^(?:$)/],conditions:{'action':{rules:[0,1,2,3,4,5,6,7,8,81,82,83,87,88,89,90,91],inclusive:false},'code':{rules:[63,74,75,87,88,89,90,91],inclusive:false},'path':{rules:[29,30,76,77,78,79,80,87,88,89,90,91],inclusive:false},'options':{rules:[24,25,29,30,32,33,34,87,88,89,90,91],inclusive:false},'option_values':{rules:[26,27,28,29,30,31,34,84,85,86,87,88,89,90,91],inclusive:false},'token':{rules:[9,10,11,29,30,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'bnf':{rules:[12,13,14,15,16,17,18,29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'ebnf':{rules:[12,13,14,15,16,17,18,19,20,21,22,23,29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'INITIAL':{rules:[29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true}}};var rmCommonWS=helpers.rmCommonWS;var dquote=helpers.dquote;// unescape a string value which is wrapped in quotes/doublequotes -function unescQuote(str){str=''+str;var a=str.split('\\\\');a=a.map(function(s){return s.replace(/\\'/g,'\'').replace(/\\"/g,'"');});str=a.join('\\\\');return str;}lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser$2.lexer=lexer$1;var ebnf=false;var rmCommonWS$1=helpers.rmCommonWS;var dquote$1=helpers.dquote;var checkActionBlock$1=helpers.checkActionBlock;// transform ebnf to bnf if necessary + `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: \/\*[^]*?\*\/ */0:43,/*! Conditions:: action */ /*! Rule:: \/\/[^\r\n]* */1:43,/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */3:43,/*! Conditions:: action */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */4:43,/*! Conditions:: action */ /*! Rule:: [/"'][^{}/"']+ */5:43,/*! Conditions:: action */ /*! Rule:: [^{}/"']+ */6:43,/*! Conditions:: bnf ebnf */ /*! Rule:: %empty\b */13:39,/*! Conditions:: bnf ebnf */ /*! Rule:: %epsilon\b */14:39,/*! Conditions:: bnf ebnf */ /*! Rule:: Ɛ */15:39,/*! Conditions:: bnf ebnf */ /*! Rule:: ɛ */16:39,/*! Conditions:: bnf ebnf */ /*! Rule:: ε */17:39,/*! Conditions:: bnf ebnf */ /*! Rule:: ϵ */18:39,/*! Conditions:: ebnf */ /*! Rule:: \( */19:7,/*! Conditions:: ebnf */ /*! Rule:: \) */20:8,/*! Conditions:: ebnf */ /*! Rule:: \* */21:9,/*! Conditions:: ebnf */ /*! Rule:: \? */22:10,/*! Conditions:: ebnf */ /*! Rule:: \+ */23:11,/*! Conditions:: options */ /*! Rule:: {NAME} */24:25,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: {ID} */38:24,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: {NAME} */39:25,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: \$end\b */40:41,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: \$eof\b */41:41,/*! Conditions:: token */ /*! Rule:: [^\s\r\n]+ */44:'TOKEN_WORD',/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: : */45:5,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: ; */46:4,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: \| */47:6,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %debug\b */50:19,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %parser-type\b */51:32,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %prec\b */52:42,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %start\b */53:16,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %left\b */54:33,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %right\b */55:34,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %nonassoc\b */56:35,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %parse-param[s]? */58:31,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %code\b */61:23,/*! Conditions:: token bnf ebnf INITIAL */ /*! Rule:: %import\b */62:22,/*! Conditions:: code */ /*! Rule:: [^\r\n]*(\r|\n)+ */74:46,/*! Conditions:: * */ /*! Rule:: $ */91:1},rules:[/* 0: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 1: */ /^(?:\/\/[^\r\n]*)/,/* 2: */ /^(?:\/[^ /]*?['"{}][^ ]*?\/)/,/* 3: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 4: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 5: */ /^(?:[/"'][^{}/"']+)/,/* 6: */ /^(?:[^{}/"']+)/,/* 7: */ /^(?:\{)/,/* 8: */ /^(?:\})/,/* 9: */ /^(?:(\r\n|\n|\r))/,/* 10: */ /^(?:%%)/,/* 11: */ /^(?:;)/,/* 12: */ /^(?:%%)/,/* 13: */ /^(?:%empty\b)/,/* 14: */ /^(?:%epsilon\b)/,/* 15: */ /^(?:Ɛ)/,/* 16: */ /^(?:ɛ)/,/* 17: */ /^(?:ε)/,/* 18: */ /^(?:ϵ)/,/* 19: */ /^(?:\()/,/* 20: */ /^(?:\))/,/* 21: */ /^(?:\*)/,/* 22: */ /^(?:\?)/,/* 23: */ /^(?:\+)/,/* 24: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?))',''),/* 25: */ /^(?:=)/,/* 26: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 27: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 28: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 29: */ /^(?:\/\/[^\r\n]*)/,/* 30: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 31: */ /^(?:\S+)/,/* 32: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 33: */ /^(?:(\r\n|\n|\r))/,/* 34: */ /^(?:([^\S\n\r])+)/,/* 35: */ /^(?:([^\S\n\r])+)/,/* 36: */ /^(?:(\r\n|\n|\r)+)/,/* 37: */new XRegExp__default['default']('^(?:\\[([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\])',''),/* 38: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 39: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?))',''),/* 40: */ /^(?:\$end\b)/,/* 41: */ /^(?:\$eof\b)/,/* 42: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 43: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 44: */ /^(?:\S+)/,/* 45: */ /^(?::)/,/* 46: */ /^(?:;)/,/* 47: */ /^(?:\|)/,/* 48: */ /^(?:%%)/,/* 49: */ /^(?:%ebnf\b)/,/* 50: */ /^(?:%debug\b)/,/* 51: */ /^(?:%parser-type\b)/,/* 52: */ /^(?:%prec\b)/,/* 53: */ /^(?:%start\b)/,/* 54: */ /^(?:%left\b)/,/* 55: */ /^(?:%right\b)/,/* 56: */ /^(?:%nonassoc\b)/,/* 57: */ /^(?:%token\b)/,/* 58: */ /^(?:%parse-param[s]?)/,/* 59: */ /^(?:%option[s]?)/,/* 60: */ /^(?:%lex((?:[^\S\n\r])*(?:(?:\r\n|\n|\r)[\s\S]*?)?(?:\r\n|\n|\r)(?:[^\S\n\r])*)\/lex\b)/,/* 61: */ /^(?:%code\b)/,/* 62: */ /^(?:%import\b)/,/* 63: */ /^(?:%include\b)/,/* 64: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 65: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 66: */ /^(?:\{\{([\s\S]*?)\}\})/,/* 67: */ /^(?:%\{([\s\S]*?)%\})/,/* 68: */ /^(?:\{)/,/* 69: */ /^(?:->.*)/,/* 70: */ /^(?:→.*)/,/* 71: */ /^(?:=>.*)/,/* 72: */ /^(?:(0[Xx][\dA-Fa-f]+))/,/* 73: */ /^(?:([1-9]\d*)(?![\dA-FXa-fx]))/,/* 74: */ /^(?:[^\r\n]*(\r|\n)+)/,/* 75: */ /^(?:[^\r\n]+)/,/* 76: */ /^(?:(\r\n|\n|\r))/,/* 77: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 78: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 79: */ /^(?:([^\S\n\r])+)/,/* 80: */ /^(?:\S+)/,/* 81: */ /^(?:")/,/* 82: */ /^(?:')/,/* 83: */ /^(?:`)/,/* 84: */ /^(?:")/,/* 85: */ /^(?:')/,/* 86: */ /^(?:`)/,/* 87: */ /^(?:")/,/* 88: */ /^(?:')/,/* 89: */ /^(?:`)/,/* 90: */ /^(?:.)/,/* 91: */ /^(?:$)/],conditions:{'action':{rules:[0,1,2,3,4,5,6,7,8,81,82,83,87,88,89,90,91],inclusive:false},'code':{rules:[63,74,75,87,88,89,90,91],inclusive:false},'path':{rules:[29,30,76,77,78,79,80,87,88,89,90,91],inclusive:false},'options':{rules:[24,25,29,30,32,33,34,87,88,89,90,91],inclusive:false},'option_values':{rules:[26,27,28,29,30,31,34,84,85,86,87,88,89,90,91],inclusive:false},'token':{rules:[9,10,11,29,30,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'bnf':{rules:[12,13,14,15,16,17,18,29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'ebnf':{rules:[12,13,14,15,16,17,18,19,20,21,22,23,29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true},'INITIAL':{rules:[29,30,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,87,88,89,90,91],inclusive:true}}};const rmCommonWS=helpers.rmCommonWS;const dquote=helpers.dquote;// unescape a string value which is wrapped in quotes/doublequotes +function unescQuote(str){str=''+str;let a=str.split('\\\\');a=a.map(function(s){return s.replace(/\\'/g,'\'').replace(/\\"/g,'"');});str=a.join('\\\\');return str;}lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser$2.lexer=lexer$1;var ebnf=false;const rmCommonWS$1=helpers.rmCommonWS;const dquote$1=helpers.dquote;const checkActionBlock$1=helpers.checkActionBlock;const trimActionCode$1=helpers.trimActionCode;// transform ebnf to bnf if necessary function extend(json,grammar){if(ebnf){json.ebnf=grammar.grammar;// keep the original source EBNF around for possible pretty-printing & AST exports. json.bnf=transform(grammar.grammar);}else{json.bnf=grammar.grammar;}if(grammar.actionInclude){json.actionInclude=grammar.actionInclude;}return json;}// convert string value to number or boolean value, when possible // (and when this is more or less obviously the intent) // otherwise produce the string itself as value. function parseValue(v){if(v==='false'){return false;}if(v==='true'){return true;}// http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) -if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$2.warn=function p_warn(){console.warn.apply(console,arguments);};parser$2.log=function p_log(){console.log.apply(console,arguments);};function Parser$1(){this.yy={};}Parser$1.prototype=parser$2;parser$2.Parser=Parser$1;function yyparse$1(){return parser$2.parse.apply(parser$2,arguments);}var bnf={parser:parser$2,Parser:Parser$1,parse:yyparse$1};// See also: +if(v&&!isNaN(v)){let rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$2.warn=function p_warn(){console.warn.apply(console,arguments);};parser$2.log=function p_log(){console.log.apply(console,arguments);};function Parser$1(){this.yy={};}Parser$1.prototype=parser$2;parser$2.Parser=Parser$1;function yyparse$1(){return parser$2.parse.apply(parser$2,arguments);}var bnf={parser:parser$2,Parser:Parser$1,parse:yyparse$1};// See also: // http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508 // but we keep the prototype.constructor and prototype.name assignment lines too for compatibility // with userland code which might access the derived class in a 'classic' way. @@ -3522,10 +3552,10 @@ let yy=this.yy;let yyparser=yy.parser;let yylexer=yy.lexer;const OPTION_DOES_NOT this.$=yyvstack[yysp-1];this._$=yylstack[yysp-1];// END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break;case 1:/*! Production:: lex : init definitions rules_and_epilogue EOF */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];for(var key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: +{this.$=yyvstack[yysp-1];for(let key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: -for(key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){var asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: -if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +for(let key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){let asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: +if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;}case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if(yyvstack[yysp]){this.$={rules:yyvstack[yysp-1],moduleInclude:yyvstack[yysp]};}else{this.$={rules:yyvstack[yysp-1]};}break;case 3:/*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) @@ -3586,7 +3616,7 @@ yy.startConditions={};// hash table // fail. yy.__context_description__=['???CONTEXT???'];yy.pushContextDescription=function(str){yy.__context_description__.push(str);};yy.popContextDescription=function(){if(yy.__context_description__.length>1){yy.__context_description__.pop();}else{yyparser.yyError('__context_description__ stack depleted! Contact a developer!');}};yy.getContextDescription=function(){return yy.__context_description__[yy.__context_description__.length-1];};break;case 8:/*! Production:: definitions : definitions definition */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];if(yyvstack[yysp]){switch(yyvstack[yysp].type){case'macro':this.$.macros[yyvstack[yysp].name]=yyvstack[yysp].body;break;case'names':var condition_defs=yyvstack[yysp].names;for(var i=0,len=condition_defs.length;i=0){var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$2` +console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0){let marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -3897,7 +3927,7 @@ console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0 Technical error report: ${yyvstack[yysp].errStr} - `);}this.$=yyvstack[yysp-2];break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];}break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` \`${yy.__options_category_description__}\` statements must be placed in @@ -3956,14 +3986,14 @@ yyparser.yyError(rmCommonWS$2` this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 59:/*! Production:: rule : regex ACTION_START action ACTION_END */case 60:/*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);var rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` +{let srcCode=trimActionCode$2(yyvstack[yysp-1],yyvstack[yysp-2]);let rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` The lexer rule's action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION_CODE so that the action chunk test/compiler +{let srcCode=trimActionCode$2(yyvstack[yysp-1]);// 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. // @@ -3974,7 +4004,7 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION // By doing this, we simplify the token return replacement code replacement // process which will be applied to the parsed lexer before its code // will be generated by JISON. -if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}var rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` +if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}let rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` The lexer rule's 'arrow' action code section does not compile: ${rv} # NOTE that the arrow action automatically wraps the action code @@ -3983,7 +4013,7 @@ if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='retur Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` A lexer rule action arrow must be followed by a single JavaScript expression specifying the lexer token to produce, e.g.: @@ -4103,8 +4133,8 @@ yyparser.yyError(rmCommonWS$2` this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 73:/*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -this.$=yyvstack[yysp-2].map(function(el){var name=el[0];// Validate the given condition state: when it isn't known, print an error message +{// rewrite + accept star '*' as name + check if we allow empty list? +this.$=yyvstack[yysp-2].map(function(el){let name=el[0];// Validate the given condition state: when it isn't known, print an error message // accordingly: if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError(rmCommonWS$2` You specified an unknown lexer condition state '${name}'. @@ -4123,10 +4153,10 @@ if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError ${yylexer.prettyPrintRange(yylstack[yysp-2],yylstack[yysp-3],yylstack[yysp])} `);}return name;});// '<' '*' '>' // { $$ = ['*']; } -break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): +}break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$2` +{// rewrite + accept star '*' as name + check if we allow empty list? +let lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$2` Seems you did not correctly terminate the start condition set <${lst.join(',')},???> with a terminating '>' @@ -4136,9 +4166,9 @@ var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCom Technical error report: ${yyvstack[yysp].errStr} - `);break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// Detect if the regex ends with a pure (Unicode) word; +{// Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are // all valid 'words' for the 'easy keyword rules' option: @@ -4176,7 +4206,7 @@ this.$=this.$.replace(/\\\\/g,'.').replace(/"/g,'.').replace(/\\c[A-Z]/g,'.').re this.$=JSON.parse('"'+this.$+'"');}catch(ex){yyparser.warn('easy-keyword-rule FAIL on eval: ',ex);// make the next keyword test fail: this.$='.';}// a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: -var re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +let re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp];break;case 78:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) @@ -4238,17 +4268,17 @@ if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/ this.$=yyvstack[yysp];}else{this.$=yyvstack[yysp];}//yyparser.log("name expansion for: ", { name: $name_expansion, redux: $name_expansion.replace(/[{}]/g, ''), output: $$ }); break;case 111:/*! Production:: literal_string : STRING_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var src=yyvstack[yysp];var s=src.substring(1,src.length-1);var edge=src[0];this.$=encodeRegexLiteralStr(s,edge);break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +{let src=yyvstack[yysp];let s=src.substring(1,src.length-1);let edge=src[0];this.$=encodeRegexLiteralStr(s,edge);}break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +{let s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);}break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal behaviour under the given circumstances, i.e. parser context: +{// validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$2` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp]),yylstack[yysp-4])} - `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){var optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$2` + `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){let optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$2` You may not separate entries in a ${yy.__options_category_description__} statement using commas. Use whitespace instead, e.g.: @@ -4256,7 +4286,7 @@ if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyErro Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);}break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$2` @@ -4289,7 +4319,7 @@ yyparser.yyError(rmCommonWS$2` ${yyvstack[yysp].errStr} `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) -var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` +{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. Erroneous area: @@ -4297,14 +4327,14 @@ var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&O Technical error report: ${yyvstack[yysp].errStr} - `);break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: +{// validate that this is legal input under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES){this.$=mkIdentifier$1(yyvstack[yysp]);// check if the transformation is obvious & trivial to humans; // if not, report an error as we don't want confusion due to // typos and/or garbage input here producing something that // is usable from a machine perspective. -if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` +if(!isLegalIdentifierInput$1(yyvstack[yysp])){let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -4312,10 +4342,10 @@ if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optiona Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}}else{this.$=yyvstack[yysp];}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}else{this.$=yyvstack[yysp];}}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: -if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` +{// validate that this is legal input under the given circumstances, i.e. parser context: +if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$2` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -4323,7 +4353,7 @@ if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_fl Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=JSON5__default['default'].parse(yyvstack[yysp]);break;case 123:/*! Production:: option_value : OPTION_VALUE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) @@ -4331,12 +4361,12 @@ this.$=parseValue$1(yyvstack[yysp]);break;case 124:/*! Production:: epilogue this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 125:/*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){var rv=checkActionBlock$2(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$2` +{let srcCode=trimActionCode$2(yyvstack[yysp]);if(srcCode){let rv=checkActionBlock$2(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$2` The '%%' lexer epilogue code does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-1])} - `);}}this.$=srcCode;break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$=srcCode;}break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` There's an error in your lexer epilogue code block. @@ -4359,7 +4389,7 @@ yyparser.yyError(rmCommonWS$2` ${yyvstack[yysp].errStr} `);this.$='';break;case 130:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` +{let srcCode=trimActionCode$2(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){let rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} Erroneous area: @@ -4367,9 +4397,9 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var `);}}// Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) // we append those protective double newlines right now, as the calling site // won't do it for us: -this.$='\n\n'+srcCode+'\n\n';break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): +this.$='\n\n'+srcCode+'\n\n';}break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$2` +{let start_marker=yyvstack[yysp-1].trim();yyparser.yyError(rmCommonWS$2` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -4377,14 +4407,14 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$='';break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);this.$='';}break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // these code chunks are very probably incomplete, hence compile-testing // for these should be deferred until we've collected the entire epilogue. this.$=yyvstack[yysp];break;case 134:/*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) -// check if there is only 1 unvalued options: 'path' -var lst=yyvstack[yysp-1];var len=lst.length;var path;if(len===1&&lst[0][1]===true){// `path`: +{// check if there is only 1 unvalued options: 'path' +let lst=yyvstack[yysp-1];let len=lst.length;let path;if(len===1&&lst[0][1]===true){// `path`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$2` You did not specify a legal file path for the '%include' statement, which must have the format: %include file_path @@ -4404,12 +4434,12 @@ path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$2` Technical error report: ${$error.errStr} `);}// **Aside**: And no, we don't support nested '%include'! -var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var srcCode=trimActionCode$1(fileContent);if(srcCode){var rv=checkActionBlock$2(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$2` +let fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});let srcCode=trimActionCode$2(fileContent);if(srcCode){let rv=checkActionBlock$2(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$2` The source code included from file '${path}' does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(this._$)} - `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';}break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` %include MUST be followed by a valid file path. @@ -5583,8 +5613,8 @@ yy_.yyerror(rmCommonWS` return 35;case 5:/*! Conditions:: action */ /*! Rule:: \/\/.* */yy.include_command_allowed=false;return 35;case 6:/*! Conditions:: action */ /*! Rule:: \| */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 7:/*! Conditions:: action */ /*! Rule:: %% */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 8:/*! Conditions:: action */ /*! Rule:: \/(?=\s) */return 35;// most probably a `/` divide operator. -case 9:/*! Conditions:: action */ /*! Rule:: \/.* */yy.include_command_allowed=false;var l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: -this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` +case 9:/*! Conditions:: action */ /*! Rule:: \/.* */{yy.include_command_allowed=false;let l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: +this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;}case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` too many closing curly braces in lexer rule action block. Note: the action code chunk may be too complex for jison to parse @@ -5604,16 +5634,16 @@ return 23;}case 18:/*! Conditions:: action */ /*! Rule:: $ */yy.include_co to help jison grok more or less complex action code chunks. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */{yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). -var marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: +let marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own, i.e. is not a rule action, %code // section, etc... -//var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); -//var precedingStr = this.matched.substr(-this.match.length - 1, 1); -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? -var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: +//let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); +//let precedingStr = this.matched.substr(-this.match.length - 1, 1); +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? +let endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: // we'd better make sure that end marker indeed does exist in the // remainder of the input! When it's not, we'll have the `action` // lexer state running past its due date as it'll then go and spit @@ -5623,7 +5653,7 @@ var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity c // Writing the wrong end marker is a common user mistake, we can // easily look ahead and check for it now and report a proper hint // to cover this failure mode in a more helpful manner. -var remaining=this.lookAhead();var prevEnd=0;var endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, +let remaining=this.lookAhead();let prevEnd=0;let endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd=endMarkerIndex+endMarker.length;continue;}if(endMarkerIndex<0){yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the @@ -5634,7 +5664,7 @@ if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd= `+this.prettyPrintRange(yy_.yylloc));return 24;}break;}// Allow the start marker to be re-matched by the generated lexer rule regex: this.unput(marker);// Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: yy_.yytext=marker;// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); +if(atSOL){return 22;}return 25;}case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */{yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); this.pushState('action');// Do a bit of magic that's useful for the parser when we // call `trimActionCode()` in there to perform a bit of // rough initial action code chunk cleanup: @@ -5659,27 +5689,27 @@ this.pushState('action');// Do a bit of magic that's useful for the parser when // follow after `trimActionCode()` has passed once we // get to the parser productions which process this // upcoming action code block. -var la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser -}return 25;case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse +let la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser +}return 25;}case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);return 25;case 32:/*! Conditions:: options */ /*! Rule:: > */this.popState();this.unput(yy_.yytext);return 21;case 35:/*! Conditions:: options */ /*! Rule:: <{ID}> */yy_.yytext=this.matches[1];return'TOKEN_TYPE';case 37:/*! Conditions:: options */ /*! Rule:: {BR}{WS}+(?=\S) */ /* ignore */break;case 38:/*! Conditions:: options */ /*! Rule:: {BR} */this.popState();this.unput(yy_.yytext);return 21;case 39:/*! Conditions:: options */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 40:/*! Conditions:: INITIAL */ /*! Rule:: {ID} */this.pushState('macro');return 19;case 41:/*! Conditions:: macro */ /*! Rule:: {BR}+ */this.popState();this.unput(yy_.yytext);return 20;case 42:/*! Conditions:: macro */ /*! Rule:: $ */this.popState();this.unput(yy_.yytext);return 20;case 43:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {BR}+ */ /* skip newlines */break;case 44:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 48:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {ANY_LITERAL_CHAR}+ */ // accept any non-regex, non-lex, non-string-delim, // non-escape-starter, non-space character as-is return 50;case 49:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \[ */this.pushState('set');return 45;case 64:/*! Conditions:: rules macro INITIAL */ /*! Rule:: < */this.pushState('options');return 3;case 66:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/! */return 41;// treated as `(?!atom)` case 67:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/ */return 13;// treated as `(?=atom)` -case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */var m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A -var v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 -var v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A -var v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[5],16);yy_.yytext=v;}return 43;case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: +case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */{let m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A +let v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 +let v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A +let v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[5],16);yy_.yytext=v;}return 43;}case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */{yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own. -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` +if(atSOL){return 22;}return 25;}case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` ignoring unsupported lexer option ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -5712,22 +5742,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` unterminated string constant in %options entry. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 101:/*! Conditions:: * */ /*! Rule:: ' */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 101:/*! Conditions:: * */ /*! Rule:: ' */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 102:/*! Conditions:: * */ /*! Rule:: ` */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 102:/*! Conditions:: * */ /*! Rule:: ` */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 103:/*! Conditions:: macro rules */ /*! Rule:: . */ /* b0rk on bad characters */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 103:/*! Conditions:: macro rules */ /*! Rule:: . */{/* b0rk on bad characters */let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -5739,7 +5769,7 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` regex expression here in jison-lex ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 2;}case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` unsupported lexer input: ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -5753,22 +5783,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` while lexing in ${dquote(this.topState())} state. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};var rmCommonWS=helpers.rmCommonWS;var dquote=helpers.dquote;var scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a + `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};const rmCommonWS=helpers.rmCommonWS;const dquote=helpers.dquote;const scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a // lexer rule to match when the need arrises: lexer.setupDelimitedActionChunkLexerRegex=function lexer__setupDelimitedActionChunkLexerRegex(marker){// Special: when we encounter `{` as the start of the action code block, // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! -var doNotPatch=marker==='{';var action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! +let doNotPatch=marker==='{';let action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! // // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) -var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. +let spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps // speed up those activities a tiny bit. -spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regexes;var len=spec.__rule_count;var rules=spec.rules;var i;var action_chunk_regex;// Must we still locate the rule to patch or have we done +spec=this.__currentRuleSet__=this._currentRules();}let regexes=spec.__rule_regexes;let len=spec.__rule_count;let rules=spec.rules;let i;let action_chunk_regex;// Must we still locate the rule to patch or have we done // that already during a previous encounter? // // WARNING: our cache/patch must live beyond the current lexer+parser invocation: @@ -5781,10 +5811,10 @@ spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regex if(!spec.__action_chunk_rule_idx){// **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! -var orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';var orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. +let orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';let orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! -for(i=1;i<=len;i++){var rule_re=regexes[i];var re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); +for(i=1;i<=len;i++){let rule_re=regexes[i];let re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if(re_str===orig_re_str1||re_str===orig_re_str2){spec.__action_chunk_rule_idx=i;break;}}if(!spec.__action_chunk_rule_idx){//console.error('ruleset dump:', spec); throw new Error('INTERNAL DEV ERROR: cannot locate %{...%} rule regex!');}// As we haven't initialized yet, we're sure the rule cache doesn't exist either. // Make it happen: @@ -5794,7 +5824,7 @@ spec.__cached_action_chunk_rule={};// set up empty cache action_chunk_regex=spec.__cached_action_chunk_rule[marker];if(!action_chunk_regex){action_chunk_regex=spec.__cached_action_chunk_rule[marker]=new RegExp('^(?:'+marker.replace(/\{/g,'\\{')+'([^]*?)'+action_end_marker.replace(/\}/g,'\\}')+'(?!\\}))');//console.warn('encode new action block regex:', action_chunk_regex); }//console.error('new ACTION REGEX:', { i, action_chunk_regex }); // and patch the lexer regex table for the current lexer condition state: -regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser$3.lexer=lexer$2;var rmCommonWS$2=helpers.rmCommonWS;var checkActionBlock$2=helpers.checkActionBlock;var mkIdentifier$1=helpers.mkIdentifier;var isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;var trimActionCode$1=helpers.trimActionCode;// see also: +regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser$3.lexer=lexer$2;const rmCommonWS$2=helpers.rmCommonWS;const checkActionBlock$2=helpers.checkActionBlock;const mkIdentifier$1=helpers.mkIdentifier;const isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;const trimActionCode$2=helpers.trimActionCode;// see also: // - https://en.wikipedia.org/wiki/C0_and_C1_control_codes // - https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-escapes-in-regular-expressions // - https://kangax.github.io/compat-table/es6/#test-RegExp_y_and_u_flags @@ -5806,27 +5836,27 @@ const charCvtTable={// "\a": "\x07", "\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v"};const escCvtTable={"a":"\\x07","e":"\\x1B","b":"\\x08","f":"\\f","n":"\\n","r":"\\r","t":"\\t","v":"\\v"};const codeCvtTable={12:"\\f",10:"\\n",13:"\\r",9:"\\t",11:"\\v"};// Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){var rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); -for(var i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead +const codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){let rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); +for(let i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. -var m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s +let m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s rv+='\\\\'+m[1];i+=m[1].length-1;continue;}if(m[2]){// [2]: regex special characters, which occur in a literal string: `\[` --> \\\[ rv+='\\\\\\'+m[2];i+=m[2].length-1;continue;}if(m[3]){// [3]: special escape characters, which occur in a literal string: `\a` --> BELL rv+=escCvtTable[m[3]];i+=m[3].length-1;continue;}if(m[4]){// [4]: octal char: `\012` --> \x0A -var v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 -var v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A -var v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: +let v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 +let v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A +let v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: rv+='\\\\';i--;continue;default:// escape regex operators: -var pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}var cc=charCvtTable[c];if(cc){rv+=cc;continue;}var cc=c.charCodeAt(0);if(cc<32){var rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); +let pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}let cc=charCvtTable[c];if(cc){rv+=cc;continue;}cc=c.charCodeAt(0);if(cc<32){let rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); return s;}// convert string value to number or boolean value, when possible // (and when this is more or less obviously the intent) // otherwise produce the string itself as value. function parseValue$1(v){if(v==='false'){return false;}if(v==='true'){return true;}// http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) -if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$3.warn=function p_warn(){console.warn.apply(console,arguments);};parser$3.log=function p_log(){console.log.apply(console,arguments);};parser$3.pre_parse=function p_lex(){if(parser$3.yydebug)parser$3.log('pre_parse:',arguments);};parser$3.yy.pre_parse=function p_lex(){if(parser$3.yydebug)parser$3.log('pre_parse YY:',arguments);};parser$3.yy.post_lex=function p_lex(){if(parser$3.yydebug)parser$3.log('post_lex:',arguments);};function Parser$2(){this.yy={};}Parser$2.prototype=parser$3;parser$3.Parser=Parser$2;function yyparse$2(){return parser$3.parse.apply(parser$3,arguments);}var jisonlex={parser:parser$3,Parser:Parser$2,parse:yyparse$2};const version='0.6.2-220';// require('./package.json').version; +if(v&&!isNaN(v)){let rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$3.warn=function p_warn(){console.warn.apply(console,arguments);};parser$3.log=function p_log(){console.log.apply(console,arguments);};parser$3.pre_parse=function p_lex(){if(parser$3.yydebug)parser$3.log('pre_parse:',arguments);};parser$3.yy.pre_parse=function p_lex(){if(parser$3.yydebug)parser$3.log('pre_parse YY:',arguments);};parser$3.yy.post_lex=function p_lex(){if(parser$3.yydebug)parser$3.log('post_lex:',arguments);};function Parser$2(){this.yy={};}Parser$2.prototype=parser$3;parser$3.Parser=Parser$2;function yyparse$2(){return parser$3.parse.apply(parser$3,arguments);}var jisonlex={parser:parser$3,Parser:Parser$2,parse:yyparse$2};const version='0.6.2-220';// require('./package.json').version; function parse(grammar){return bnf.parser.parse(grammar);}// adds a declaration to the grammar bnf.parser.yy.addDeclaration=function bnfAddDeclaration(grammar,decl){if(!decl){return;}if(decl.start){grammar.start=decl.start;}if(decl.lex){grammar.lex=parseLex(decl.lex.text,decl.lex.position);}if(decl.grammar){grammar.grammar=decl.grammar;}if(decl.ebnf){grammar.ebnf=decl.ebnf;}if(decl.bnf){grammar.bnf=decl.bnf;}if(decl.operator){if(!grammar.operators)grammar.operators=[];grammar.operators.push(decl.operator);}if(decl.token){if(!grammar.extra_tokens)grammar.extra_tokens=[];grammar.extra_tokens.push(decl.token);}if(decl.token_list){if(!grammar.extra_tokens)grammar.extra_tokens=[];decl.token_list.forEach(function(tok){grammar.extra_tokens.push(tok);});}if(decl.parseParams){if(!grammar.parseParams)grammar.parseParams=[];grammar.parseParams=grammar.parseParams.concat(decl.parseParams);}if(decl.parserType){if(!grammar.options)grammar.options={};grammar.options.type=decl.parserType;}if(decl.include){if(!grammar.moduleInclude){grammar.moduleInclude=decl.include;}else{grammar.moduleInclude+='\n\n'+decl.include;}}if(decl.actionInclude){if(!grammar.actionInclude){grammar.actionInclude=decl.actionInclude;}else{grammar.actionInclude+='\n\n'+decl.actionInclude;}}if(decl.options){if(!grammar.options)grammar.options={};// last occurrence of `%options` wins: for(let i=0;i= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -15345,6 +15452,7 @@ `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -15510,8 +15618,9 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The lexer rule's action code section does not compile: ${rv} @@ -15521,6 +15630,7 @@ `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -15531,7 +15641,8 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1]); // 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. @@ -15549,7 +15660,7 @@ srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -15564,6 +15675,7 @@ } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -15809,9 +15921,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -15839,6 +15952,7 @@ // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -15850,8 +15964,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -15866,6 +15981,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -15876,6 +15992,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -15930,13 +16047,14 @@ } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -16224,10 +16342,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -16238,8 +16358,10 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -16250,6 +16372,7 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$2` @@ -16260,7 +16383,7 @@ `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -16277,6 +16400,7 @@ } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -16372,7 +16496,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -16385,6 +16510,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -16395,6 +16521,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -16403,7 +16530,7 @@ // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -16420,6 +16547,7 @@ } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -16430,11 +16558,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -16448,6 +16577,7 @@ ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -16491,9 +16621,10 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$2(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$2(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The '%%' lexer epilogue code does not compile: ${rv} @@ -16504,6 +16635,7 @@ } } this.$ = srcCode; + } break; case 126: @@ -16555,9 +16687,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$2(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$2(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -16571,6 +16704,7 @@ // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -16581,8 +16715,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$2` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -16593,6 +16727,7 @@ ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -16616,10 +16751,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -16648,11 +16784,11 @@ } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$2(fileContent); if (srcCode) { - var rv = checkActionBlock$2(srcCode, this._$, yy); + let rv = checkActionBlock$2(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$2` The source code included from file '${path}' does not compile: ${rv} @@ -16664,6 +16800,7 @@ } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -21813,21 +21950,22 @@ case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -21921,55 +22059,55 @@ case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -21977,24 +22115,25 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -22022,44 +22161,45 @@ case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -22184,38 +22324,39 @@ case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -22255,29 +22396,30 @@ case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -22381,49 +22523,56 @@ case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -22437,7 +22586,8 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -23014,9 +23164,9 @@ } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -23025,9 +23175,9 @@ // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -23035,7 +23185,7 @@ // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -23045,11 +23195,11 @@ spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -23065,15 +23215,15 @@ // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -23133,11 +23283,11 @@ }(); parser$3.lexer = lexer$2; - var rmCommonWS$2 = helpers.rmCommonWS; - var checkActionBlock$2 = helpers.checkActionBlock; - var mkIdentifier$1 = helpers.mkIdentifier; - var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; - var trimActionCode$1 = helpers.trimActionCode; + const rmCommonWS$2 = helpers.rmCommonWS; + const checkActionBlock$2 = helpers.checkActionBlock; + const mkIdentifier$1 = helpers.mkIdentifier; + const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; + const trimActionCode$2 = helpers.trimActionCode; // see also: @@ -23178,11 +23328,11 @@ // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. - var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; + const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -23192,7 +23342,7 @@ function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -23201,10 +23351,10 @@ } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -23214,7 +23364,7 @@ rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -23227,7 +23377,7 @@ // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -23249,35 +23399,35 @@ } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -23291,19 +23441,19 @@ default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -23334,7 +23484,7 @@ // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/ebnf-parser/parser.js b/packages/ebnf-parser/parser.js index 38fc65160..6c66f9cc8 100644 --- a/packages/ebnf-parser/parser.js +++ b/packages/ebnf-parser/parser.js @@ -1106,8 +1106,6 @@ case 4: /*! Production:: optional_end_block : %epsilon */ case 101: /*! Production:: suffix : %epsilon */ -case 117: - /*! Production:: action : %epsilon */ case 118: /*! Production:: action_body : %epsilon */ case 133: @@ -1129,7 +1127,8 @@ case 5: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS` The extra parser module code section (a.k.a. 'epilogue') does not compile: ${rv} @@ -1139,6 +1138,7 @@ case 5: `); } this.$ = yyvstack[yysp]; + } break; case 6: @@ -1164,8 +1164,9 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS` action header code block does not compile: ${rv} @@ -1175,6 +1176,7 @@ case 8: `); } yy.addDeclaration(this.$, { actionInclude: yyvstack[yysp] }); + } break; case 9: @@ -1258,7 +1260,8 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS` action code block does not compile: ${rv} @@ -1268,6 +1271,7 @@ case 16: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 17: @@ -1278,7 +1282,8 @@ case 17: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS` action header code block does not compile: ${rv} @@ -1288,6 +1293,7 @@ case 17: `); } this.$ = {include: yyvstack[yysp]}; + } break; case 18: @@ -1414,7 +1420,8 @@ case 27: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); + { + let rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); if (rv) { yyparser.yyError(rmCommonWS` %code "${$init_code_name}" initialization section action code block does not compile: ${rv} @@ -1429,6 +1436,7 @@ case 27: include: yyvstack[yysp] } }; + } break; case 28: @@ -1544,8 +1552,6 @@ case 113: /*! Production:: action_ne : ACTION */ case 114: /*! Production:: action_ne : include_macro_code */ -case 115: - /*! Production:: action : action_ne */ case 119: /*! Production:: action_body : action_comments_body */ case 123: @@ -1845,17 +1851,19 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var rv = []; - var lst = yyvstack[yysp]; - for (var i = 0, len = lst.length; i < len; i++) { - var id = lst[i]; - var m = {id: id}; + { + let rv = []; + let lst = yyvstack[yysp]; + for (let i = 0, len = lst.length; i < len; i++) { + let id = lst[i]; + let m = {id: id}; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } rv.push(m); } this.$ = rv; + } break; case 62: @@ -1866,11 +1874,13 @@ case 62: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var m = yyvstack[yysp]; + { + let m = yyvstack[yysp]; if (yyvstack[yysp - 1]) { m.type = yyvstack[yysp - 1]; } this.$ = [m]; + } break; case 63: @@ -2148,18 +2158,37 @@ case 87: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { this.$ = [(yyvstack[yysp - 2].length ? yyvstack[yysp - 2].join(' ') : '')]; if (yyvstack[yysp]) { - var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS` - production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS` + production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } else { + let indentedSrc = rmCommonWS([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS` + production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { @@ -2175,6 +2204,7 @@ case 87: if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 88: @@ -2185,22 +2215,42 @@ case 88: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = ['']; if (yyvstack[yysp]) { - var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); + let rv = checkActionBlock(yyvstack[yysp].action, yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS` - epsilon production rule action code block does not compile: ${rv} + if (!yyvstack[yysp].isArrowAction) { + yyparser.yyError(rmCommonWS` + epsilon production rule action code block does not compile: ${rv} - Erroneous area: - ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} - `); + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } else { + let indentedSrc = rmCommonWS([yyvstack[yysp].action]).split('\n').join('\n '); + + yyparser.yyError(rmCommonWS` + epsilon production rule arrow action code block does not compile: ${rv} + + Please be aware that the reported compile error MAY be referring + to the wrapper code which is added by JISON automatically when + processing arrow actions: the entire action code chunk + (including wrapper) is: + + ${indentedSrc} + + Erroneous area: + ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} + `); + } } - this.$.push(yyvstack[yysp]); + this.$.push(yyvstack[yysp].action); } if (this.$.length === 1) { this.$ = this.$[0]; } + } break; case 89: @@ -2381,6 +2431,8 @@ case 106: case 107: /*! Production:: prec : %epsilon */ +case 117: + /*! Production:: action : %epsilon */ // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); @@ -2407,6 +2459,20 @@ case 112: `); break; +case 115: + /*! Production:: action : action_ne */ + + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + this._$ = yylstack[yysp]; + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + + + this.$ = { + action: yyvstack[yysp], + isArrowAction: false + }; + break; + case 116: /*! Production:: action : ARROW_ACTION */ @@ -2415,7 +2481,17 @@ case 116: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - this.$ = '$$ = (\n' + yyvstack[yysp] + '\n);'; + { + let src = trimActionCode(yyvstack[yysp]); + this.$ = { + action: ` + this.$ = ( + ${src} + ); + `, + isArrowAction: true + }; + } break; case 120: @@ -2476,8 +2552,9 @@ case 127: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var fileContent = fs.readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); - var rv = checkActionBlock(fileContent); + { + let fileContent = fs.readFileSync(yyvstack[yysp], { encoding: 'utf-8' }); + let rv = checkActionBlock(fileContent); if (rv) { yyparser.yyError(rmCommonWS` included action code file "${$PATH}" does not compile: ${rv} @@ -2488,6 +2565,7 @@ case 127: } // And no, we don't support nested '%include': this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n'; + } break; case 128: @@ -7757,44 +7835,53 @@ var lexer = function() { case 87: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } + break; case 88: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } + break; case 89: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 'UNTERMINATED_STRING_ERROR'; + return 'UNTERMINATED_STRING_ERROR'; + } + break; case 90: /*! Conditions:: * */ @@ -8330,19 +8417,19 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; function indent(s, i) { - var a = s.split('\n'); - var pf = new Array(i + 1).join(' '); + let a = s.split('\n'); + let pf = new Array(i + 1).join(' '); return pf + a.join('\n' + pf); } // unescape a string value which is wrapped in quotes/doublequotes function unescQuote(str) { str = '' + str; - var a = str.split('\\\\'); + let a = str.split('\\\\'); a = a.map(function(s) { return s.replace(/\\'/g, '\'').replace(/\\"/g, '"'); @@ -8378,9 +8465,10 @@ var ebnf = false; -var rmCommonWS = helpers.rmCommonWS; -var dquote = helpers.dquote; -var checkActionBlock = helpers.checkActionBlock; +const rmCommonWS = helpers.rmCommonWS; +const dquote = helpers.dquote; +const checkActionBlock = helpers.checkActionBlock; +const trimActionCode = helpers.trimActionCode; // transform ebnf to bnf if necessary @@ -8411,7 +8499,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/ebnf-parser/tests/specs/output/0029-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/output/0029-test.jison-ref.json5 index 85bd701fe..b2e7ab94e 100644 --- a/packages/ebnf-parser/tests/specs/output/0029-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/output/0029-test.jison-ref.json5 @@ -3,9 +3,11 @@ test: [ [ 'foo bar', - `$$ = ( -$foo -);`, + ` + this.$ = ( + $foo + ); + `, ], ], }, diff --git a/packages/ebnf-parser/tests/specs/output/1013-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/output/1013-test.jison-ref.json5 index bdaac6f32..e09ef9891 100644 --- a/packages/ebnf-parser/tests/specs/output/1013-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/output/1013-test.jison-ref.json5 @@ -29,11 +29,11 @@ multiple alternative rule productions should be separated by a '|' pipe characte ^...........^^^^ 7: - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7472:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:7482:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/output/1014-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/output/1014-test.jison-ref.json5 index 7c3a5299d..5401100cd 100644 --- a/packages/ebnf-parser/tests/specs/output/1014-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/output/1014-test.jison-ref.json5 @@ -11,9 +11,9 @@ bogus: foo bar; name: 'JisonParserError', message: '$id is not defined', stack: `ReferenceError: $id is not defined - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7404:32) - at Object.parse (/ebnf-parser-cjs.js:10707:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:7414:32) + at Object.parse (/ebnf-parser-cjs.js:10785:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/output/1015-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/output/1015-test.jison-ref.json5 index 1e411d369..5255a83ef 100644 --- a/packages/ebnf-parser/tests/specs/output/1015-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/output/1015-test.jison-ref.json5 @@ -33,11 +33,11 @@ multiple alternative rule productions should be separated by a '|' pipe characte 5: 6: bogus: foo bar; - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7472:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:7482:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/output/1016-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/output/1016-test.jison-ref.json5 index 91511f85f..eebce2f59 100644 --- a/packages/ebnf-parser/tests/specs/output/1016-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/output/1016-test.jison-ref.json5 @@ -23,11 +23,11 @@ Maybe you did not correctly separate the parse 'header section' (token definitio 3: ^..^ - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) at Object.parser__PerformAction (/ebnf-parser-cjs.js:6434:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/output/1017-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/output/1017-test.jison-ref.json5 index 91b71e753..fc05ed984 100644 --- a/packages/ebnf-parser/tests/specs/output/1017-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/output/1017-test.jison-ref.json5 @@ -26,11 +26,11 @@ declaration list error? 4: %% ^..^^ - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6538:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:6540:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/output/1018-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/output/1018-test.jison-ref.json5 index fd58cb861..08f781a1f 100644 --- a/packages/ebnf-parser/tests/specs/output/1018-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/output/1018-test.jison-ref.json5 @@ -44,11 +44,11 @@ Parse error on line 12: ^ Expecting ":", "STRING", "ARROW_ACTION", "optional_production_description", got unexpected "%%" - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7382:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:7392:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/output/1019-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/output/1019-test.jison-ref.json5 index 9a1327aa3..f52fdd73c 100644 --- a/packages/ebnf-parser/tests/specs/output/1019-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/output/1019-test.jison-ref.json5 @@ -39,11 +39,11 @@ declaration list error? 7: 8: foo: bar; - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6538:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:6540:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/reference-output/0029-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/reference-output/0029-test.jison-ref.json5 index 85bd701fe..b2e7ab94e 100644 --- a/packages/ebnf-parser/tests/specs/reference-output/0029-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/reference-output/0029-test.jison-ref.json5 @@ -3,9 +3,11 @@ test: [ [ 'foo bar', - `$$ = ( -$foo -);`, + ` + this.$ = ( + $foo + ); + `, ], ], }, diff --git a/packages/ebnf-parser/tests/specs/reference-output/1013-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/reference-output/1013-test.jison-ref.json5 index bdaac6f32..e09ef9891 100644 --- a/packages/ebnf-parser/tests/specs/reference-output/1013-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/reference-output/1013-test.jison-ref.json5 @@ -29,11 +29,11 @@ multiple alternative rule productions should be separated by a '|' pipe characte ^...........^^^^ 7: - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7472:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:7482:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/reference-output/1014-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/reference-output/1014-test.jison-ref.json5 index 7c3a5299d..5401100cd 100644 --- a/packages/ebnf-parser/tests/specs/reference-output/1014-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/reference-output/1014-test.jison-ref.json5 @@ -11,9 +11,9 @@ bogus: foo bar; name: 'JisonParserError', message: '$id is not defined', stack: `ReferenceError: $id is not defined - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7404:32) - at Object.parse (/ebnf-parser-cjs.js:10707:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:7414:32) + at Object.parse (/ebnf-parser-cjs.js:10785:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/reference-output/1015-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/reference-output/1015-test.jison-ref.json5 index 1e411d369..5255a83ef 100644 --- a/packages/ebnf-parser/tests/specs/reference-output/1015-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/reference-output/1015-test.jison-ref.json5 @@ -33,11 +33,11 @@ multiple alternative rule productions should be separated by a '|' pipe characte 5: 6: bogus: foo bar; - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7472:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:7482:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/reference-output/1016-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/reference-output/1016-test.jison-ref.json5 index 91511f85f..eebce2f59 100644 --- a/packages/ebnf-parser/tests/specs/reference-output/1016-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/reference-output/1016-test.jison-ref.json5 @@ -23,11 +23,11 @@ Maybe you did not correctly separate the parse 'header section' (token definitio 3: ^..^ - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) at Object.parser__PerformAction (/ebnf-parser-cjs.js:6434:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/reference-output/1017-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/reference-output/1017-test.jison-ref.json5 index 91b71e753..fc05ed984 100644 --- a/packages/ebnf-parser/tests/specs/reference-output/1017-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/reference-output/1017-test.jison-ref.json5 @@ -26,11 +26,11 @@ declaration list error? 4: %% ^..^^ - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6538:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:6540:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/reference-output/1018-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/reference-output/1018-test.jison-ref.json5 index fd58cb861..08f781a1f 100644 --- a/packages/ebnf-parser/tests/specs/reference-output/1018-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/reference-output/1018-test.jison-ref.json5 @@ -44,11 +44,11 @@ Parse error on line 12: ^ Expecting ":", "STRING", "ARROW_ACTION", "optional_production_description", got unexpected "%%" - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7382:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:7392:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/ebnf-parser/tests/specs/reference-output/1019-test.jison-ref.json5 b/packages/ebnf-parser/tests/specs/reference-output/1019-test.jison-ref.json5 index 9a1327aa3..f52fdd73c 100644 --- a/packages/ebnf-parser/tests/specs/reference-output/1019-test.jison-ref.json5 +++ b/packages/ebnf-parser/tests/specs/reference-output/1019-test.jison-ref.json5 @@ -39,11 +39,11 @@ declaration list error? 7: 8: foo: bar; - at Object.parseError (/ebnf-parser-cjs.js:9257:15) - at Object.yyError (/ebnf-parser-cjs.js:9440:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6538:14) - at Object.parse (/ebnf-parser-cjs.js:10504:24) - at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Object.parseError (/ebnf-parser-cjs.js:9335:15) + at Object.yyError (/ebnf-parser-cjs.js:9518:25) + at Object.parser__PerformAction (/ebnf-parser-cjs.js:6540:14) + at Object.parse (/ebnf-parser-cjs.js:10582:24) + at Object.parse (/ebnf-parser-cjs.js:23544:23) at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/Makefile b/packages/jison-lex/Makefile index 039033ed3..c5cb5714d 100644 --- a/packages/jison-lex/Makefile +++ b/packages/jison-lex/Makefile @@ -6,9 +6,9 @@ MOCHA = ../../node_modules/.bin/mocha NYC = ../../node_modules/.bin/nyc --clean=false --temp-directory ../../.nyc_output ifndef FULL_CODE_COVERAGE - LEX = node ./dist/cli-cjs-es5.js -o ./output/$@/ + LEX = node ./dist/cli-cjs.js -o ./output/$@/ else - LEX = $(NYC) --reporter=lcov -- node ./dist/cli-cjs-es5.js -o ./output/$@/ + LEX = $(NYC) --reporter=lcov -- node ./dist/cli-cjs.js -o ./output/$@/ endif diff --git a/packages/jison-lex/dist/cli-cjs-es5.js b/packages/jison-lex/dist/cli-cjs-es5.js index 50df9acb6..ee21d9d34 100644 --- a/packages/jison-lex/dist/cli-cjs-es5.js +++ b/packages/jison-lex/dist/cli-cjs-es5.js @@ -716,10 +716,10 @@ let yy=this.yy;let yyparser=yy.parser;let yylexer=yy.lexer;const OPTION_DOES_NOT this.$=yyvstack[yysp-1];this._$=yylstack[yysp-1];// END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break;case 1:/*! Production:: lex : init definitions rules_and_epilogue EOF */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];for(var key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: +{this.$=yyvstack[yysp-1];for(let key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: -for(key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){var asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: -if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +for(let key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){let asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: +if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;}case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if(yyvstack[yysp]){this.$={rules:yyvstack[yysp-1],moduleInclude:yyvstack[yysp]};}else{this.$={rules:yyvstack[yysp-1]};}break;case 3:/*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) @@ -780,7 +780,7 @@ yy.startConditions={};// hash table // fail. yy.__context_description__=['???CONTEXT???'];yy.pushContextDescription=function(str){yy.__context_description__.push(str);};yy.popContextDescription=function(){if(yy.__context_description__.length>1){yy.__context_description__.pop();}else{yyparser.yyError('__context_description__ stack depleted! Contact a developer!');}};yy.getContextDescription=function(){return yy.__context_description__[yy.__context_description__.length-1];};break;case 8:/*! Production:: definitions : definitions definition */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];if(yyvstack[yysp]){switch(yyvstack[yysp].type){case'macro':this.$.macros[yyvstack[yysp].name]=yyvstack[yysp].body;break;case'names':var condition_defs=yyvstack[yysp].names;for(var i=0,len=condition_defs.length;i=0){var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` +console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0){let marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -1091,7 +1091,7 @@ console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0 Technical error report: ${yyvstack[yysp].errStr} - `);}this.$=yyvstack[yysp-2];break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];}break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` \`${yy.__options_category_description__}\` statements must be placed in @@ -1150,14 +1150,14 @@ yyparser.yyError(rmCommonWS$1` this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 59:/*! Production:: rule : regex ACTION_START action ACTION_END */case 60:/*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION_CODE so that the action chunk test/compiler +{let srcCode=trimActionCode$1(yyvstack[yysp-1]);// 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. // @@ -1168,7 +1168,7 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION // By doing this, we simplify the token return replacement code replacement // process which will be applied to the parsed lexer before its code // will be generated by JISON. -if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} # NOTE that the arrow action automatically wraps the action code @@ -1177,7 +1177,7 @@ if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='retur Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule action arrow must be followed by a single JavaScript expression specifying the lexer token to produce, e.g.: @@ -1297,8 +1297,8 @@ yyparser.yyError(rmCommonWS$1` this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 73:/*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -this.$=yyvstack[yysp-2].map(function(el){var name=el[0];// Validate the given condition state: when it isn't known, print an error message +{// rewrite + accept star '*' as name + check if we allow empty list? +this.$=yyvstack[yysp-2].map(function(el){let name=el[0];// Validate the given condition state: when it isn't known, print an error message // accordingly: if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError(rmCommonWS$1` You specified an unknown lexer condition state '${name}'. @@ -1317,10 +1317,10 @@ if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError ${yylexer.prettyPrintRange(yylstack[yysp-2],yylstack[yysp-3],yylstack[yysp])} `);}return name;});// '<' '*' '>' // { $$ = ['*']; } -break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): +}break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$1` +{// rewrite + accept star '*' as name + check if we allow empty list? +let lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$1` Seems you did not correctly terminate the start condition set <${lst.join(',')},???> with a terminating '>' @@ -1330,9 +1330,9 @@ var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCom Technical error report: ${yyvstack[yysp].errStr} - `);break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// Detect if the regex ends with a pure (Unicode) word; +{// Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are // all valid 'words' for the 'easy keyword rules' option: @@ -1370,7 +1370,7 @@ this.$=this.$.replace(/\\\\/g,'.').replace(/"/g,'.').replace(/\\c[A-Z]/g,'.').re this.$=JSON.parse('"'+this.$+'"');}catch(ex){yyparser.warn('easy-keyword-rule FAIL on eval: ',ex);// make the next keyword test fail: this.$='.';}// a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: -var re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +let re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp];break;case 78:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) @@ -1432,17 +1432,17 @@ if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/ this.$=yyvstack[yysp];}else{this.$=yyvstack[yysp];}//yyparser.log("name expansion for: ", { name: $name_expansion, redux: $name_expansion.replace(/[{}]/g, ''), output: $$ }); break;case 111:/*! Production:: literal_string : STRING_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var src=yyvstack[yysp];var s=src.substring(1,src.length-1);var edge=src[0];this.$=encodeRegexLiteralStr(s,edge);break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +{let src=yyvstack[yysp];let s=src.substring(1,src.length-1);let edge=src[0];this.$=encodeRegexLiteralStr(s,edge);}break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +{let s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);}break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal behaviour under the given circumstances, i.e. parser context: +{// validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$1` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp]),yylstack[yysp-4])} - `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){var optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$1` + `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){let optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$1` You may not separate entries in a ${yy.__options_category_description__} statement using commas. Use whitespace instead, e.g.: @@ -1450,7 +1450,7 @@ if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyErro Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);}break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$1` @@ -1483,7 +1483,7 @@ yyparser.yyError(rmCommonWS$1` ${yyvstack[yysp].errStr} `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) -var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. Erroneous area: @@ -1491,14 +1491,14 @@ var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&O Technical error report: ${yyvstack[yysp].errStr} - `);break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: +{// validate that this is legal input under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES){this.$=mkIdentifier$1(yyvstack[yysp]);// check if the transformation is obvious & trivial to humans; // if not, report an error as we don't want confusion due to // typos and/or garbage input here producing something that // is usable from a machine perspective. -if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +if(!isLegalIdentifierInput$1(yyvstack[yysp])){let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -1506,10 +1506,10 @@ if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optiona Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}}else{this.$=yyvstack[yysp];}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}else{this.$=yyvstack[yysp];}}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: -if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +{// validate that this is legal input under the given circumstances, i.e. parser context: +if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -1517,7 +1517,7 @@ if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_fl Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=JSON5__default['default'].parse(yyvstack[yysp]);break;case 123:/*! Production:: option_value : OPTION_VALUE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) @@ -1525,12 +1525,12 @@ this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 125:/*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){let rv=checkActionBlock$1(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-1])} - `);}}this.$=srcCode;break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$=srcCode;}break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` There's an error in your lexer epilogue code block. @@ -1553,7 +1553,7 @@ yyparser.yyError(rmCommonWS$1` ${yyvstack[yysp].errStr} `);this.$='';break;case 130:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} Erroneous area: @@ -1561,9 +1561,9 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var `);}}// Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) // we append those protective double newlines right now, as the calling site // won't do it for us: -this.$='\n\n'+srcCode+'\n\n';break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): +this.$='\n\n'+srcCode+'\n\n';}break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` +{let start_marker=yyvstack[yysp-1].trim();yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -1571,14 +1571,14 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$='';break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);this.$='';}break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // these code chunks are very probably incomplete, hence compile-testing // for these should be deferred until we've collected the entire epilogue. this.$=yyvstack[yysp];break;case 134:/*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) -// check if there is only 1 unvalued options: 'path' -var lst=yyvstack[yysp-1];var len=lst.length;var path;if(len===1&&lst[0][1]===true){// `path`: +{// check if there is only 1 unvalued options: 'path' +let lst=yyvstack[yysp-1];let len=lst.length;let path;if(len===1&&lst[0][1]===true){// `path`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` You did not specify a legal file path for the '%include' statement, which must have the format: %include file_path @@ -1598,12 +1598,12 @@ path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` Technical error report: ${$error.errStr} `);}// **Aside**: And no, we don't support nested '%include'! -var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var srcCode=trimActionCode$1(fileContent);if(srcCode){var rv=checkActionBlock$1(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$1` +let fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});let srcCode=trimActionCode$1(fileContent);if(srcCode){let rv=checkActionBlock$1(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(this._$)} - `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';}break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` %include MUST be followed by a valid file path. @@ -2777,8 +2777,8 @@ yy_.yyerror(rmCommonWS` return 35;case 5:/*! Conditions:: action */ /*! Rule:: \/\/.* */yy.include_command_allowed=false;return 35;case 6:/*! Conditions:: action */ /*! Rule:: \| */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 7:/*! Conditions:: action */ /*! Rule:: %% */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 8:/*! Conditions:: action */ /*! Rule:: \/(?=\s) */return 35;// most probably a `/` divide operator. -case 9:/*! Conditions:: action */ /*! Rule:: \/.* */yy.include_command_allowed=false;var l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: -this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` +case 9:/*! Conditions:: action */ /*! Rule:: \/.* */{yy.include_command_allowed=false;let l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: +this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;}case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` too many closing curly braces in lexer rule action block. Note: the action code chunk may be too complex for jison to parse @@ -2798,16 +2798,16 @@ return 23;}case 18:/*! Conditions:: action */ /*! Rule:: $ */yy.include_co to help jison grok more or less complex action code chunks. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */{yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). -var marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: +let marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own, i.e. is not a rule action, %code // section, etc... -//var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); -//var precedingStr = this.matched.substr(-this.match.length - 1, 1); -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? -var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: +//let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); +//let precedingStr = this.matched.substr(-this.match.length - 1, 1); +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? +let endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: // we'd better make sure that end marker indeed does exist in the // remainder of the input! When it's not, we'll have the `action` // lexer state running past its due date as it'll then go and spit @@ -2817,7 +2817,7 @@ var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity c // Writing the wrong end marker is a common user mistake, we can // easily look ahead and check for it now and report a proper hint // to cover this failure mode in a more helpful manner. -var remaining=this.lookAhead();var prevEnd=0;var endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, +let remaining=this.lookAhead();let prevEnd=0;let endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd=endMarkerIndex+endMarker.length;continue;}if(endMarkerIndex<0){yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the @@ -2828,7 +2828,7 @@ if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd= `+this.prettyPrintRange(yy_.yylloc));return 24;}break;}// Allow the start marker to be re-matched by the generated lexer rule regex: this.unput(marker);// Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: yy_.yytext=marker;// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); +if(atSOL){return 22;}return 25;}case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */{yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); this.pushState('action');// Do a bit of magic that's useful for the parser when we // call `trimActionCode()` in there to perform a bit of // rough initial action code chunk cleanup: @@ -2853,27 +2853,27 @@ this.pushState('action');// Do a bit of magic that's useful for the parser when // follow after `trimActionCode()` has passed once we // get to the parser productions which process this // upcoming action code block. -var la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser -}return 25;case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse +let la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser +}return 25;}case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);return 25;case 32:/*! Conditions:: options */ /*! Rule:: > */this.popState();this.unput(yy_.yytext);return 21;case 35:/*! Conditions:: options */ /*! Rule:: <{ID}> */yy_.yytext=this.matches[1];return'TOKEN_TYPE';case 37:/*! Conditions:: options */ /*! Rule:: {BR}{WS}+(?=\S) */ /* ignore */break;case 38:/*! Conditions:: options */ /*! Rule:: {BR} */this.popState();this.unput(yy_.yytext);return 21;case 39:/*! Conditions:: options */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 40:/*! Conditions:: INITIAL */ /*! Rule:: {ID} */this.pushState('macro');return 19;case 41:/*! Conditions:: macro */ /*! Rule:: {BR}+ */this.popState();this.unput(yy_.yytext);return 20;case 42:/*! Conditions:: macro */ /*! Rule:: $ */this.popState();this.unput(yy_.yytext);return 20;case 43:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {BR}+ */ /* skip newlines */break;case 44:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 48:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {ANY_LITERAL_CHAR}+ */ // accept any non-regex, non-lex, non-string-delim, // non-escape-starter, non-space character as-is return 50;case 49:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \[ */this.pushState('set');return 45;case 64:/*! Conditions:: rules macro INITIAL */ /*! Rule:: < */this.pushState('options');return 3;case 66:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/! */return 41;// treated as `(?!atom)` case 67:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/ */return 13;// treated as `(?=atom)` -case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */var m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A -var v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 -var v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A -var v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[5],16);yy_.yytext=v;}return 43;case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: +case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */{let m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A +let v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 +let v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A +let v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[5],16);yy_.yytext=v;}return 43;}case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */{yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own. -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` +if(atSOL){return 22;}return 25;}case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` ignoring unsupported lexer option ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -2906,22 +2906,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` unterminated string constant in %options entry. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 101:/*! Conditions:: * */ /*! Rule:: ' */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 101:/*! Conditions:: * */ /*! Rule:: ' */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 102:/*! Conditions:: * */ /*! Rule:: ` */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 102:/*! Conditions:: * */ /*! Rule:: ` */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 103:/*! Conditions:: macro rules */ /*! Rule:: . */ /* b0rk on bad characters */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 103:/*! Conditions:: macro rules */ /*! Rule:: . */{/* b0rk on bad characters */let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -2933,7 +2933,7 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` regex expression here in jison-lex ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 2;}case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` unsupported lexer input: ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -2947,22 +2947,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` while lexing in ${dquote(this.topState())} state. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};var rmCommonWS=helpers.rmCommonWS;var dquote=helpers.dquote;var scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a + `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};const rmCommonWS=helpers.rmCommonWS;const dquote=helpers.dquote;const scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a // lexer rule to match when the need arrises: lexer.setupDelimitedActionChunkLexerRegex=function lexer__setupDelimitedActionChunkLexerRegex(marker){// Special: when we encounter `{` as the start of the action code block, // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! -var doNotPatch=marker==='{';var action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! +let doNotPatch=marker==='{';let action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! // // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) -var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. +let spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps // speed up those activities a tiny bit. -spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regexes;var len=spec.__rule_count;var rules=spec.rules;var i;var action_chunk_regex;// Must we still locate the rule to patch or have we done +spec=this.__currentRuleSet__=this._currentRules();}let regexes=spec.__rule_regexes;let len=spec.__rule_count;let rules=spec.rules;let i;let action_chunk_regex;// Must we still locate the rule to patch or have we done // that already during a previous encounter? // // WARNING: our cache/patch must live beyond the current lexer+parser invocation: @@ -2975,10 +2975,10 @@ spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regex if(!spec.__action_chunk_rule_idx){// **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! -var orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';var orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. +let orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';let orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! -for(i=1;i<=len;i++){var rule_re=regexes[i];var re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); +for(i=1;i<=len;i++){let rule_re=regexes[i];let re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if(re_str===orig_re_str1||re_str===orig_re_str2){spec.__action_chunk_rule_idx=i;break;}}if(!spec.__action_chunk_rule_idx){//console.error('ruleset dump:', spec); throw new Error('INTERNAL DEV ERROR: cannot locate %{...%} rule regex!');}// As we haven't initialized yet, we're sure the rule cache doesn't exist either. // Make it happen: @@ -2988,7 +2988,7 @@ spec.__cached_action_chunk_rule={};// set up empty cache action_chunk_regex=spec.__cached_action_chunk_rule[marker];if(!action_chunk_regex){action_chunk_regex=spec.__cached_action_chunk_rule[marker]=new RegExp('^(?:'+marker.replace(/\{/g,'\\{')+'([^]*?)'+action_end_marker.replace(/\}/g,'\\}')+'(?!\\}))');//console.warn('encode new action block regex:', action_chunk_regex); }//console.error('new ACTION REGEX:', { i, action_chunk_regex }); // and patch the lexer regex table for the current lexer condition state: -regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser.lexer=lexer;var rmCommonWS$1=helpers.rmCommonWS;var checkActionBlock$1=helpers.checkActionBlock;var mkIdentifier$1=helpers.mkIdentifier;var isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;var trimActionCode$1=helpers.trimActionCode;// see also: +regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser.lexer=lexer;const rmCommonWS$1=helpers.rmCommonWS;const checkActionBlock$1=helpers.checkActionBlock;const mkIdentifier$1=helpers.mkIdentifier;const isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;const trimActionCode$1=helpers.trimActionCode;// see also: // - https://en.wikipedia.org/wiki/C0_and_C1_control_codes // - https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-escapes-in-regular-expressions // - https://kangax.github.io/compat-table/es6/#test-RegExp_y_and_u_flags @@ -3000,27 +3000,27 @@ const charCvtTable={// "\a": "\x07", "\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v"};const escCvtTable={"a":"\\x07","e":"\\x1B","b":"\\x08","f":"\\f","n":"\\n","r":"\\r","t":"\\t","v":"\\v"};const codeCvtTable={12:"\\f",10:"\\n",13:"\\r",9:"\\t",11:"\\v"};// Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){var rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); -for(var i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead +const codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){let rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); +for(let i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. -var m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s +let m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s rv+='\\\\'+m[1];i+=m[1].length-1;continue;}if(m[2]){// [2]: regex special characters, which occur in a literal string: `\[` --> \\\[ rv+='\\\\\\'+m[2];i+=m[2].length-1;continue;}if(m[3]){// [3]: special escape characters, which occur in a literal string: `\a` --> BELL rv+=escCvtTable[m[3]];i+=m[3].length-1;continue;}if(m[4]){// [4]: octal char: `\012` --> \x0A -var v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 -var v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A -var v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: +let v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 +let v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A +let v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: rv+='\\\\';i--;continue;default:// escape regex operators: -var pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}var cc=charCvtTable[c];if(cc){rv+=cc;continue;}var cc=c.charCodeAt(0);if(cc<32){var rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); +let pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}let cc=charCvtTable[c];if(cc){rv+=cc;continue;}cc=c.charCodeAt(0);if(cc<32){let rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); return s;}// convert string value to number or boolean value, when possible // (and when this is more or less obviously the intent) // otherwise produce the string itself as value. function parseValue(v){if(v==='false'){return false;}if(v==='true'){return true;}// http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) -if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser.warn=function p_warn(){console.warn.apply(console,arguments);};parser.log=function p_log(){console.log.apply(console,arguments);};parser.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse:',arguments);};parser.yy.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse YY:',arguments);};parser.yy.post_lex=function p_lex(){if(parser.yydebug)parser.log('post_lex:',arguments);};function Parser(){this.yy={};}Parser.prototype=parser;parser.Parser=Parser;function yyparse(){return parser.parse.apply(parser,arguments);}var lexParser={parser,Parser,parse:yyparse};// +if(v&&!isNaN(v)){let rv=+v;if(isFinite(rv)){return rv;}}return v;}parser.warn=function p_warn(){console.warn.apply(console,arguments);};parser.log=function p_log(){console.log.apply(console,arguments);};parser.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse:',arguments);};parser.yy.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse YY:',arguments);};parser.yy.post_lex=function p_lex(){if(parser.yydebug)parser.log('post_lex:',arguments);};function Parser(){this.yy={};}Parser.prototype=parser;parser.Parser=Parser;function yyparse(){return parser.parse.apply(parser,arguments);}var lexParser={parser,Parser,parse:yyparse};// const XREGEXP_UNICODE_ESCAPE_RE=/^\{[A-Za-z0-9 \-\._]+\}/;// Matches the XRegExp Unicode escape braced part, e.g. `{Number}` const CHR_RE=/^(?:[^\\]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})/;const SET_PART_RE=/^(?:[^\\\]]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;const NOTHING_SPECIAL_RE=/^(?:[^\\\[\]\(\)\|^\{\}]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;const SET_IS_SINGLE_PCODE_RE=/^\\[dDwWsS]$|^\\p\{[A-Za-z0-9 \-\._]+\}$/;const UNICODE_BASE_PLANE_MAX_CP=65535;// The expanded regex sets which are equivalent to the given `\\{c}` escapes: // @@ -3323,7 +3323,10 @@ action=helpers.printFunctionSourceCodeContainer(action).code;}action=action.repl // which would then cause havoc when our action code analysis (using regexes or otherwise) was 'too simple' // to catch these culprits; hence we resort and stick with the most fundamental approach here: // always append `break;` even when it would be obvious to a human that such would be 'unreachable code'. -let match_nr=/^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim());if(match_nr){simple_rule_count++;caseHelper.push([].concat(code,i,':',match_nr[1]).join(' ').replace(/[\n]/g,'\n '));}else{regular_rule_count++;routingCode.push([].concat('case',i,':',code,action,'\nbreak;').join(' '));}}if(simple_rule_count){routingCode.push('default:');routingCode.push(' return this.simpleCaseActionClusters[yyrulenumber];');}routingCode.push('}');// only inject the big switch/case chunk when there's any `switch` or `default` branch to switch to: +let match_nr=/^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim());if(match_nr){simple_rule_count++;caseHelper.push([].concat(code,i,':',match_nr[1]).join(' ').replace(/[\n]/g,'\n '));}else{regular_rule_count++;// If action includes the keyword `let` or `const`, then it's ES6 code +// which must be scoped to prevent collisions with other action code chunks +// in the same large generated switch/case statement: +if(/\blet\b/.test(action)||/\bconst\b/.test(action)){action='{\n'+action+'\n}';}routingCode.push([].concat('case',i,':',code,action,'\nbreak;').join(' '));}}if(simple_rule_count){routingCode.push('default:');routingCode.push(' return this.simpleCaseActionClusters[yyrulenumber];');}routingCode.push('}');// only inject the big switch/case chunk when there's any `switch` or `default` branch to switch to: if(simple_rule_count+regular_rule_count>0){actions.push.apply(actions,routingCode);}else{actions.push('/* no rules ==> no rule SWITCH! */');}return{rules:newRules,// array listing only the lexer spec regexes macros:macros,regular_rule_count:regular_rule_count,simple_rule_count:simple_rule_count};}// expand all macros (with maybe one exception) in the given regex: the macros may exist inside `[...]` regex sets or // elsewhere, which requires two different treatments to expand these macros. diff --git a/packages/jison-lex/dist/cli-cjs.js b/packages/jison-lex/dist/cli-cjs.js index 652980772..eb8ce1d90 100644 --- a/packages/jison-lex/dist/cli-cjs.js +++ b/packages/jison-lex/dist/cli-cjs.js @@ -2565,20 +2565,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2588,6 +2589,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2737,6 +2739,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2745,9 +2748,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -2794,6 +2797,7 @@ case 8: break; } } + } break; case 9: @@ -2878,8 +2882,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -2887,6 +2892,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -2917,8 +2923,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -2926,6 +2933,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -2956,9 +2964,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -2970,6 +2979,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -2995,8 +3005,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3017,8 +3025,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3033,6 +3042,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3043,11 +3053,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3092,10 +3104,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3124,6 +3137,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3157,10 +3171,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3182,8 +3197,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3199,6 +3214,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3210,9 +3226,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3226,6 +3243,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3438,9 +3456,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3452,6 +3471,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3475,8 +3495,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3487,6 +3507,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3497,13 +3518,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3533,6 +3555,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3698,8 +3721,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3709,6 +3733,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3719,7 +3744,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3737,7 +3763,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3752,6 +3778,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3997,9 +4024,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4027,6 +4055,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4038,8 +4067,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4054,6 +4084,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4064,6 +4095,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4118,13 +4150,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4412,10 +4445,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4426,8 +4461,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4438,6 +4475,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4448,7 +4486,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4465,6 +4503,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4560,7 +4599,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4573,6 +4613,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4583,6 +4624,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -4591,7 +4633,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4608,6 +4650,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4618,11 +4661,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4636,6 +4680,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4679,9 +4724,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4692,6 +4738,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4743,9 +4790,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4759,6 +4807,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4769,8 +4818,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4781,6 +4830,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -4804,10 +4854,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -4836,11 +4887,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -4852,6 +4903,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -10001,21 +10053,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10109,55 +10162,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10165,24 +10218,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10210,44 +10264,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10372,38 +10427,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10443,29 +10499,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10569,49 +10626,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10625,7 +10689,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11202,9 +11267,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11213,9 +11278,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11223,7 +11288,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11233,11 +11298,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11253,15 +11318,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11321,11 +11386,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$1 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$1 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11366,11 +11431,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11380,7 +11445,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11389,10 +11454,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11402,7 +11467,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11415,7 +11480,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11437,35 +11502,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11479,19 +11544,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11522,7 +11587,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -12908,6 +12973,12 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } diff --git a/packages/jison-lex/dist/cli-es6.js b/packages/jison-lex/dist/cli-es6.js index 7ee1030d5..f42fc689d 100644 --- a/packages/jison-lex/dist/cli-es6.js +++ b/packages/jison-lex/dist/cli-es6.js @@ -2552,20 +2552,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2575,6 +2576,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2724,6 +2726,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2732,9 +2735,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -2781,6 +2784,7 @@ case 8: break; } } + } break; case 9: @@ -2865,8 +2869,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -2874,6 +2879,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -2904,8 +2910,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -2913,6 +2920,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -2943,9 +2951,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -2957,6 +2966,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -2982,8 +2992,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3004,8 +3012,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3020,6 +3029,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3030,11 +3040,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3079,10 +3091,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3111,6 +3124,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3144,10 +3158,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3169,8 +3184,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3186,6 +3201,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3197,9 +3213,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3213,6 +3230,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3425,9 +3443,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3439,6 +3458,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3462,8 +3482,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3474,6 +3494,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3484,13 +3505,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3520,6 +3542,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3685,8 +3708,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3696,6 +3720,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3706,7 +3731,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3724,7 +3750,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3739,6 +3765,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3984,9 +4011,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4014,6 +4042,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4025,8 +4054,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4041,6 +4071,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4051,6 +4082,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4105,13 +4137,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp('\\w[\\w\\d]*$'); + let re = new XRegExp('\\w[\\w\\d]*$'); if (XRegExp.match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4399,10 +4432,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4413,8 +4448,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4425,6 +4462,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4435,7 +4473,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4452,6 +4490,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4547,7 +4586,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4560,6 +4600,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4570,6 +4611,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -4578,7 +4620,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4595,6 +4637,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4605,11 +4648,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4623,6 +4667,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4666,9 +4711,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4679,6 +4725,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4730,9 +4777,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4746,6 +4794,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4756,8 +4805,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4768,6 +4817,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -4791,10 +4841,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -4823,11 +4874,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -4839,6 +4890,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -9988,21 +10040,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10096,55 +10149,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10152,24 +10205,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10197,44 +10251,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10359,38 +10414,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10430,29 +10486,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10556,49 +10613,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10612,7 +10676,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11189,9 +11254,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11200,9 +11265,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11210,7 +11275,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11220,11 +11285,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11240,15 +11305,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11308,11 +11373,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$1 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$1 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11353,11 +11418,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11367,7 +11432,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11376,10 +11441,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11389,7 +11454,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11402,7 +11467,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11424,35 +11489,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11466,19 +11531,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11509,7 +11574,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -12895,6 +12960,12 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } diff --git a/packages/jison-lex/dist/cli-umd-es5.js b/packages/jison-lex/dist/cli-umd-es5.js index 9071ae3dc..c018051af 100644 --- a/packages/jison-lex/dist/cli-umd-es5.js +++ b/packages/jison-lex/dist/cli-umd-es5.js @@ -716,10 +716,10 @@ let yy=this.yy;let yyparser=yy.parser;let yylexer=yy.lexer;const OPTION_DOES_NOT this.$=yyvstack[yysp-1];this._$=yylstack[yysp-1];// END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break;case 1:/*! Production:: lex : init definitions rules_and_epilogue EOF */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];for(var key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: +{this.$=yyvstack[yysp-1];for(let key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: -for(key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){var asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: -if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +for(let key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){let asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: +if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;}case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if(yyvstack[yysp]){this.$={rules:yyvstack[yysp-1],moduleInclude:yyvstack[yysp]};}else{this.$={rules:yyvstack[yysp-1]};}break;case 3:/*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) @@ -780,7 +780,7 @@ yy.startConditions={};// hash table // fail. yy.__context_description__=['???CONTEXT???'];yy.pushContextDescription=function(str){yy.__context_description__.push(str);};yy.popContextDescription=function(){if(yy.__context_description__.length>1){yy.__context_description__.pop();}else{yyparser.yyError('__context_description__ stack depleted! Contact a developer!');}};yy.getContextDescription=function(){return yy.__context_description__[yy.__context_description__.length-1];};break;case 8:/*! Production:: definitions : definitions definition */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];if(yyvstack[yysp]){switch(yyvstack[yysp].type){case'macro':this.$.macros[yyvstack[yysp].name]=yyvstack[yysp].body;break;case'names':var condition_defs=yyvstack[yysp].names;for(var i=0,len=condition_defs.length;i=0){var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` +console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0){let marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -1091,7 +1091,7 @@ console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0 Technical error report: ${yyvstack[yysp].errStr} - `);}this.$=yyvstack[yysp-2];break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];}break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` \`${yy.__options_category_description__}\` statements must be placed in @@ -1150,14 +1150,14 @@ yyparser.yyError(rmCommonWS$1` this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 59:/*! Production:: rule : regex ACTION_START action ACTION_END */case 60:/*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION_CODE so that the action chunk test/compiler +{let srcCode=trimActionCode$1(yyvstack[yysp-1]);// 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. // @@ -1168,7 +1168,7 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION // By doing this, we simplify the token return replacement code replacement // process which will be applied to the parsed lexer before its code // will be generated by JISON. -if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} # NOTE that the arrow action automatically wraps the action code @@ -1177,7 +1177,7 @@ if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='retur Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule action arrow must be followed by a single JavaScript expression specifying the lexer token to produce, e.g.: @@ -1297,8 +1297,8 @@ yyparser.yyError(rmCommonWS$1` this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 73:/*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -this.$=yyvstack[yysp-2].map(function(el){var name=el[0];// Validate the given condition state: when it isn't known, print an error message +{// rewrite + accept star '*' as name + check if we allow empty list? +this.$=yyvstack[yysp-2].map(function(el){let name=el[0];// Validate the given condition state: when it isn't known, print an error message // accordingly: if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError(rmCommonWS$1` You specified an unknown lexer condition state '${name}'. @@ -1317,10 +1317,10 @@ if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError ${yylexer.prettyPrintRange(yylstack[yysp-2],yylstack[yysp-3],yylstack[yysp])} `);}return name;});// '<' '*' '>' // { $$ = ['*']; } -break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): +}break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$1` +{// rewrite + accept star '*' as name + check if we allow empty list? +let lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$1` Seems you did not correctly terminate the start condition set <${lst.join(',')},???> with a terminating '>' @@ -1330,9 +1330,9 @@ var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCom Technical error report: ${yyvstack[yysp].errStr} - `);break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// Detect if the regex ends with a pure (Unicode) word; +{// Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are // all valid 'words' for the 'easy keyword rules' option: @@ -1370,7 +1370,7 @@ this.$=this.$.replace(/\\\\/g,'.').replace(/"/g,'.').replace(/\\c[A-Z]/g,'.').re this.$=JSON.parse('"'+this.$+'"');}catch(ex){yyparser.warn('easy-keyword-rule FAIL on eval: ',ex);// make the next keyword test fail: this.$='.';}// a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: -var re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +let re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp];break;case 78:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) @@ -1432,17 +1432,17 @@ if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/ this.$=yyvstack[yysp];}else{this.$=yyvstack[yysp];}//yyparser.log("name expansion for: ", { name: $name_expansion, redux: $name_expansion.replace(/[{}]/g, ''), output: $$ }); break;case 111:/*! Production:: literal_string : STRING_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var src=yyvstack[yysp];var s=src.substring(1,src.length-1);var edge=src[0];this.$=encodeRegexLiteralStr(s,edge);break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +{let src=yyvstack[yysp];let s=src.substring(1,src.length-1);let edge=src[0];this.$=encodeRegexLiteralStr(s,edge);}break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +{let s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);}break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal behaviour under the given circumstances, i.e. parser context: +{// validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$1` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp]),yylstack[yysp-4])} - `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){var optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$1` + `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){let optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$1` You may not separate entries in a ${yy.__options_category_description__} statement using commas. Use whitespace instead, e.g.: @@ -1450,7 +1450,7 @@ if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyErro Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);}break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$1` @@ -1483,7 +1483,7 @@ yyparser.yyError(rmCommonWS$1` ${yyvstack[yysp].errStr} `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) -var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. Erroneous area: @@ -1491,14 +1491,14 @@ var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&O Technical error report: ${yyvstack[yysp].errStr} - `);break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: +{// validate that this is legal input under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES){this.$=mkIdentifier$1(yyvstack[yysp]);// check if the transformation is obvious & trivial to humans; // if not, report an error as we don't want confusion due to // typos and/or garbage input here producing something that // is usable from a machine perspective. -if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +if(!isLegalIdentifierInput$1(yyvstack[yysp])){let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -1506,10 +1506,10 @@ if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optiona Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}}else{this.$=yyvstack[yysp];}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}else{this.$=yyvstack[yysp];}}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: -if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +{// validate that this is legal input under the given circumstances, i.e. parser context: +if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -1517,7 +1517,7 @@ if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_fl Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=JSON5__default['default'].parse(yyvstack[yysp]);break;case 123:/*! Production:: option_value : OPTION_VALUE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) @@ -1525,12 +1525,12 @@ this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 125:/*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){let rv=checkActionBlock$1(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-1])} - `);}}this.$=srcCode;break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$=srcCode;}break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` There's an error in your lexer epilogue code block. @@ -1553,7 +1553,7 @@ yyparser.yyError(rmCommonWS$1` ${yyvstack[yysp].errStr} `);this.$='';break;case 130:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} Erroneous area: @@ -1561,9 +1561,9 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var `);}}// Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) // we append those protective double newlines right now, as the calling site // won't do it for us: -this.$='\n\n'+srcCode+'\n\n';break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): +this.$='\n\n'+srcCode+'\n\n';}break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` +{let start_marker=yyvstack[yysp-1].trim();yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -1571,14 +1571,14 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$='';break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);this.$='';}break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // these code chunks are very probably incomplete, hence compile-testing // for these should be deferred until we've collected the entire epilogue. this.$=yyvstack[yysp];break;case 134:/*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) -// check if there is only 1 unvalued options: 'path' -var lst=yyvstack[yysp-1];var len=lst.length;var path;if(len===1&&lst[0][1]===true){// `path`: +{// check if there is only 1 unvalued options: 'path' +let lst=yyvstack[yysp-1];let len=lst.length;let path;if(len===1&&lst[0][1]===true){// `path`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` You did not specify a legal file path for the '%include' statement, which must have the format: %include file_path @@ -1598,12 +1598,12 @@ path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` Technical error report: ${$error.errStr} `);}// **Aside**: And no, we don't support nested '%include'! -var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var srcCode=trimActionCode$1(fileContent);if(srcCode){var rv=checkActionBlock$1(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$1` +let fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});let srcCode=trimActionCode$1(fileContent);if(srcCode){let rv=checkActionBlock$1(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(this._$)} - `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';}break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` %include MUST be followed by a valid file path. @@ -2777,8 +2777,8 @@ yy_.yyerror(rmCommonWS` return 35;case 5:/*! Conditions:: action */ /*! Rule:: \/\/.* */yy.include_command_allowed=false;return 35;case 6:/*! Conditions:: action */ /*! Rule:: \| */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 7:/*! Conditions:: action */ /*! Rule:: %% */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 8:/*! Conditions:: action */ /*! Rule:: \/(?=\s) */return 35;// most probably a `/` divide operator. -case 9:/*! Conditions:: action */ /*! Rule:: \/.* */yy.include_command_allowed=false;var l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: -this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` +case 9:/*! Conditions:: action */ /*! Rule:: \/.* */{yy.include_command_allowed=false;let l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: +this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;}case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` too many closing curly braces in lexer rule action block. Note: the action code chunk may be too complex for jison to parse @@ -2798,16 +2798,16 @@ return 23;}case 18:/*! Conditions:: action */ /*! Rule:: $ */yy.include_co to help jison grok more or less complex action code chunks. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */{yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). -var marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: +let marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own, i.e. is not a rule action, %code // section, etc... -//var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); -//var precedingStr = this.matched.substr(-this.match.length - 1, 1); -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? -var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: +//let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); +//let precedingStr = this.matched.substr(-this.match.length - 1, 1); +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? +let endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: // we'd better make sure that end marker indeed does exist in the // remainder of the input! When it's not, we'll have the `action` // lexer state running past its due date as it'll then go and spit @@ -2817,7 +2817,7 @@ var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity c // Writing the wrong end marker is a common user mistake, we can // easily look ahead and check for it now and report a proper hint // to cover this failure mode in a more helpful manner. -var remaining=this.lookAhead();var prevEnd=0;var endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, +let remaining=this.lookAhead();let prevEnd=0;let endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd=endMarkerIndex+endMarker.length;continue;}if(endMarkerIndex<0){yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the @@ -2828,7 +2828,7 @@ if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd= `+this.prettyPrintRange(yy_.yylloc));return 24;}break;}// Allow the start marker to be re-matched by the generated lexer rule regex: this.unput(marker);// Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: yy_.yytext=marker;// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); +if(atSOL){return 22;}return 25;}case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */{yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); this.pushState('action');// Do a bit of magic that's useful for the parser when we // call `trimActionCode()` in there to perform a bit of // rough initial action code chunk cleanup: @@ -2853,27 +2853,27 @@ this.pushState('action');// Do a bit of magic that's useful for the parser when // follow after `trimActionCode()` has passed once we // get to the parser productions which process this // upcoming action code block. -var la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser -}return 25;case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse +let la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser +}return 25;}case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);return 25;case 32:/*! Conditions:: options */ /*! Rule:: > */this.popState();this.unput(yy_.yytext);return 21;case 35:/*! Conditions:: options */ /*! Rule:: <{ID}> */yy_.yytext=this.matches[1];return'TOKEN_TYPE';case 37:/*! Conditions:: options */ /*! Rule:: {BR}{WS}+(?=\S) */ /* ignore */break;case 38:/*! Conditions:: options */ /*! Rule:: {BR} */this.popState();this.unput(yy_.yytext);return 21;case 39:/*! Conditions:: options */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 40:/*! Conditions:: INITIAL */ /*! Rule:: {ID} */this.pushState('macro');return 19;case 41:/*! Conditions:: macro */ /*! Rule:: {BR}+ */this.popState();this.unput(yy_.yytext);return 20;case 42:/*! Conditions:: macro */ /*! Rule:: $ */this.popState();this.unput(yy_.yytext);return 20;case 43:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {BR}+ */ /* skip newlines */break;case 44:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 48:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {ANY_LITERAL_CHAR}+ */ // accept any non-regex, non-lex, non-string-delim, // non-escape-starter, non-space character as-is return 50;case 49:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \[ */this.pushState('set');return 45;case 64:/*! Conditions:: rules macro INITIAL */ /*! Rule:: < */this.pushState('options');return 3;case 66:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/! */return 41;// treated as `(?!atom)` case 67:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/ */return 13;// treated as `(?=atom)` -case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */var m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A -var v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 -var v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A -var v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[5],16);yy_.yytext=v;}return 43;case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: +case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */{let m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A +let v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 +let v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A +let v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[5],16);yy_.yytext=v;}return 43;}case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */{yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own. -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` +if(atSOL){return 22;}return 25;}case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` ignoring unsupported lexer option ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -2906,22 +2906,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` unterminated string constant in %options entry. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 101:/*! Conditions:: * */ /*! Rule:: ' */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 101:/*! Conditions:: * */ /*! Rule:: ' */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 102:/*! Conditions:: * */ /*! Rule:: ` */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 102:/*! Conditions:: * */ /*! Rule:: ` */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 103:/*! Conditions:: macro rules */ /*! Rule:: . */ /* b0rk on bad characters */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 103:/*! Conditions:: macro rules */ /*! Rule:: . */{/* b0rk on bad characters */let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -2933,7 +2933,7 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` regex expression here in jison-lex ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 2;}case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` unsupported lexer input: ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -2947,22 +2947,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` while lexing in ${dquote(this.topState())} state. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};var rmCommonWS=helpers.rmCommonWS;var dquote=helpers.dquote;var scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a + `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};const rmCommonWS=helpers.rmCommonWS;const dquote=helpers.dquote;const scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a // lexer rule to match when the need arrises: lexer.setupDelimitedActionChunkLexerRegex=function lexer__setupDelimitedActionChunkLexerRegex(marker){// Special: when we encounter `{` as the start of the action code block, // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! -var doNotPatch=marker==='{';var action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! +let doNotPatch=marker==='{';let action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! // // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) -var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. +let spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps // speed up those activities a tiny bit. -spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regexes;var len=spec.__rule_count;var rules=spec.rules;var i;var action_chunk_regex;// Must we still locate the rule to patch or have we done +spec=this.__currentRuleSet__=this._currentRules();}let regexes=spec.__rule_regexes;let len=spec.__rule_count;let rules=spec.rules;let i;let action_chunk_regex;// Must we still locate the rule to patch or have we done // that already during a previous encounter? // // WARNING: our cache/patch must live beyond the current lexer+parser invocation: @@ -2975,10 +2975,10 @@ spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regex if(!spec.__action_chunk_rule_idx){// **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! -var orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';var orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. +let orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';let orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! -for(i=1;i<=len;i++){var rule_re=regexes[i];var re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); +for(i=1;i<=len;i++){let rule_re=regexes[i];let re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if(re_str===orig_re_str1||re_str===orig_re_str2){spec.__action_chunk_rule_idx=i;break;}}if(!spec.__action_chunk_rule_idx){//console.error('ruleset dump:', spec); throw new Error('INTERNAL DEV ERROR: cannot locate %{...%} rule regex!');}// As we haven't initialized yet, we're sure the rule cache doesn't exist either. // Make it happen: @@ -2988,7 +2988,7 @@ spec.__cached_action_chunk_rule={};// set up empty cache action_chunk_regex=spec.__cached_action_chunk_rule[marker];if(!action_chunk_regex){action_chunk_regex=spec.__cached_action_chunk_rule[marker]=new RegExp('^(?:'+marker.replace(/\{/g,'\\{')+'([^]*?)'+action_end_marker.replace(/\}/g,'\\}')+'(?!\\}))');//console.warn('encode new action block regex:', action_chunk_regex); }//console.error('new ACTION REGEX:', { i, action_chunk_regex }); // and patch the lexer regex table for the current lexer condition state: -regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser.lexer=lexer;var rmCommonWS$1=helpers.rmCommonWS;var checkActionBlock$1=helpers.checkActionBlock;var mkIdentifier$1=helpers.mkIdentifier;var isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;var trimActionCode$1=helpers.trimActionCode;// see also: +regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser.lexer=lexer;const rmCommonWS$1=helpers.rmCommonWS;const checkActionBlock$1=helpers.checkActionBlock;const mkIdentifier$1=helpers.mkIdentifier;const isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;const trimActionCode$1=helpers.trimActionCode;// see also: // - https://en.wikipedia.org/wiki/C0_and_C1_control_codes // - https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-escapes-in-regular-expressions // - https://kangax.github.io/compat-table/es6/#test-RegExp_y_and_u_flags @@ -3000,27 +3000,27 @@ const charCvtTable={// "\a": "\x07", "\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v"};const escCvtTable={"a":"\\x07","e":"\\x1B","b":"\\x08","f":"\\f","n":"\\n","r":"\\r","t":"\\t","v":"\\v"};const codeCvtTable={12:"\\f",10:"\\n",13:"\\r",9:"\\t",11:"\\v"};// Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){var rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); -for(var i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead +const codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){let rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); +for(let i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. -var m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s +let m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s rv+='\\\\'+m[1];i+=m[1].length-1;continue;}if(m[2]){// [2]: regex special characters, which occur in a literal string: `\[` --> \\\[ rv+='\\\\\\'+m[2];i+=m[2].length-1;continue;}if(m[3]){// [3]: special escape characters, which occur in a literal string: `\a` --> BELL rv+=escCvtTable[m[3]];i+=m[3].length-1;continue;}if(m[4]){// [4]: octal char: `\012` --> \x0A -var v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 -var v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A -var v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: +let v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 +let v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A +let v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: rv+='\\\\';i--;continue;default:// escape regex operators: -var pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}var cc=charCvtTable[c];if(cc){rv+=cc;continue;}var cc=c.charCodeAt(0);if(cc<32){var rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); +let pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}let cc=charCvtTable[c];if(cc){rv+=cc;continue;}cc=c.charCodeAt(0);if(cc<32){let rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); return s;}// convert string value to number or boolean value, when possible // (and when this is more or less obviously the intent) // otherwise produce the string itself as value. function parseValue(v){if(v==='false'){return false;}if(v==='true'){return true;}// http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) -if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser.warn=function p_warn(){console.warn.apply(console,arguments);};parser.log=function p_log(){console.log.apply(console,arguments);};parser.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse:',arguments);};parser.yy.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse YY:',arguments);};parser.yy.post_lex=function p_lex(){if(parser.yydebug)parser.log('post_lex:',arguments);};function Parser(){this.yy={};}Parser.prototype=parser;parser.Parser=Parser;function yyparse(){return parser.parse.apply(parser,arguments);}var lexParser={parser,Parser,parse:yyparse};// +if(v&&!isNaN(v)){let rv=+v;if(isFinite(rv)){return rv;}}return v;}parser.warn=function p_warn(){console.warn.apply(console,arguments);};parser.log=function p_log(){console.log.apply(console,arguments);};parser.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse:',arguments);};parser.yy.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse YY:',arguments);};parser.yy.post_lex=function p_lex(){if(parser.yydebug)parser.log('post_lex:',arguments);};function Parser(){this.yy={};}Parser.prototype=parser;parser.Parser=Parser;function yyparse(){return parser.parse.apply(parser,arguments);}var lexParser={parser,Parser,parse:yyparse};// const XREGEXP_UNICODE_ESCAPE_RE=/^\{[A-Za-z0-9 \-\._]+\}/;// Matches the XRegExp Unicode escape braced part, e.g. `{Number}` const CHR_RE=/^(?:[^\\]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})/;const SET_PART_RE=/^(?:[^\\\]]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;const NOTHING_SPECIAL_RE=/^(?:[^\\\[\]\(\)\|^\{\}]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;const SET_IS_SINGLE_PCODE_RE=/^\\[dDwWsS]$|^\\p\{[A-Za-z0-9 \-\._]+\}$/;const UNICODE_BASE_PLANE_MAX_CP=65535;// The expanded regex sets which are equivalent to the given `\\{c}` escapes: // @@ -3323,7 +3323,10 @@ action=helpers.printFunctionSourceCodeContainer(action).code;}action=action.repl // which would then cause havoc when our action code analysis (using regexes or otherwise) was 'too simple' // to catch these culprits; hence we resort and stick with the most fundamental approach here: // always append `break;` even when it would be obvious to a human that such would be 'unreachable code'. -let match_nr=/^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim());if(match_nr){simple_rule_count++;caseHelper.push([].concat(code,i,':',match_nr[1]).join(' ').replace(/[\n]/g,'\n '));}else{regular_rule_count++;routingCode.push([].concat('case',i,':',code,action,'\nbreak;').join(' '));}}if(simple_rule_count){routingCode.push('default:');routingCode.push(' return this.simpleCaseActionClusters[yyrulenumber];');}routingCode.push('}');// only inject the big switch/case chunk when there's any `switch` or `default` branch to switch to: +let match_nr=/^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim());if(match_nr){simple_rule_count++;caseHelper.push([].concat(code,i,':',match_nr[1]).join(' ').replace(/[\n]/g,'\n '));}else{regular_rule_count++;// If action includes the keyword `let` or `const`, then it's ES6 code +// which must be scoped to prevent collisions with other action code chunks +// in the same large generated switch/case statement: +if(/\blet\b/.test(action)||/\bconst\b/.test(action)){action='{\n'+action+'\n}';}routingCode.push([].concat('case',i,':',code,action,'\nbreak;').join(' '));}}if(simple_rule_count){routingCode.push('default:');routingCode.push(' return this.simpleCaseActionClusters[yyrulenumber];');}routingCode.push('}');// only inject the big switch/case chunk when there's any `switch` or `default` branch to switch to: if(simple_rule_count+regular_rule_count>0){actions.push.apply(actions,routingCode);}else{actions.push('/* no rules ==> no rule SWITCH! */');}return{rules:newRules,// array listing only the lexer spec regexes macros:macros,regular_rule_count:regular_rule_count,simple_rule_count:simple_rule_count};}// expand all macros (with maybe one exception) in the given regex: the macros may exist inside `[...]` regex sets or // elsewhere, which requires two different treatments to expand these macros. diff --git a/packages/jison-lex/dist/cli-umd.js b/packages/jison-lex/dist/cli-umd.js index b95473653..884e7a86a 100644 --- a/packages/jison-lex/dist/cli-umd.js +++ b/packages/jison-lex/dist/cli-umd.js @@ -2559,20 +2559,21 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2582,6 +2583,7 @@ delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2731,6 +2733,7 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2739,9 +2742,9 @@ break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -2788,6 +2791,7 @@ break; } } + } break; case 9: @@ -2872,8 +2876,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -2881,6 +2886,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -2911,8 +2917,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -2920,6 +2927,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -2950,9 +2958,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -2964,6 +2973,7 @@ yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -2989,8 +2999,6 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3011,8 +3019,9 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3027,6 +3036,7 @@ ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3037,11 +3047,13 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3086,10 +3098,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3118,6 +3131,7 @@ type: 'imports', body: body }; + } break; case 24: @@ -3151,10 +3165,11 @@ // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3176,8 +3191,8 @@ `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3193,6 +3208,7 @@ include: srcCode } }; + } break; case 26: @@ -3204,9 +3220,10 @@ // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3220,6 +3237,7 @@ Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3432,9 +3450,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3446,6 +3465,7 @@ yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3469,8 +3489,8 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3481,6 +3501,7 @@ ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3491,13 +3512,14 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3527,6 +3549,7 @@ `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3692,8 +3715,9 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3703,6 +3727,7 @@ `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3713,7 +3738,8 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3731,7 +3757,7 @@ srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3746,6 +3772,7 @@ } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3991,9 +4018,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4021,6 +4049,7 @@ // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4032,8 +4061,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4048,6 +4078,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4058,6 +4089,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4112,13 +4144,14 @@ } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4406,10 +4439,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4420,8 +4455,10 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4432,6 +4469,7 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4442,7 +4480,7 @@ `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4459,6 +4497,7 @@ } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4554,7 +4593,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4567,6 +4607,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4577,6 +4618,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -4585,7 +4627,7 @@ // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4602,6 +4644,7 @@ } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4612,11 +4655,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4630,6 +4674,7 @@ ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4673,9 +4718,10 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4686,6 +4732,7 @@ } } this.$ = srcCode; + } break; case 126: @@ -4737,9 +4784,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4753,6 +4801,7 @@ // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4763,8 +4812,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4775,6 +4824,7 @@ ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -4798,10 +4848,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -4830,11 +4881,11 @@ } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -4846,6 +4897,7 @@ } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -9995,21 +10047,22 @@ case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10103,55 +10156,55 @@ case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10159,24 +10212,25 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10204,44 +10258,45 @@ case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10366,38 +10421,39 @@ case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10437,29 +10493,30 @@ case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10563,49 +10620,56 @@ case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10619,7 +10683,8 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11196,9 +11261,9 @@ } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11207,9 +11272,9 @@ // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11217,7 +11282,7 @@ // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11227,11 +11292,11 @@ spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11247,15 +11312,15 @@ // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11315,11 +11380,11 @@ }(); parser.lexer = lexer; - var rmCommonWS$1 = helpers.rmCommonWS; - var checkActionBlock$1 = helpers.checkActionBlock; - var mkIdentifier$1 = helpers.mkIdentifier; - var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; - var trimActionCode$1 = helpers.trimActionCode; + const rmCommonWS$1 = helpers.rmCommonWS; + const checkActionBlock$1 = helpers.checkActionBlock; + const mkIdentifier$1 = helpers.mkIdentifier; + const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; + const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11360,11 +11425,11 @@ // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. - var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; + const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11374,7 +11439,7 @@ function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11383,10 +11448,10 @@ } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11396,7 +11461,7 @@ rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11409,7 +11474,7 @@ // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11431,35 +11496,35 @@ } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11473,19 +11538,19 @@ default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11516,7 +11581,7 @@ // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -12902,6 +12967,12 @@ caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } diff --git a/packages/jison-lex/dist/regexp-lexer-cjs-es5.js b/packages/jison-lex/dist/regexp-lexer-cjs-es5.js index c6ed50807..c24d9eb35 100644 --- a/packages/jison-lex/dist/regexp-lexer-cjs-es5.js +++ b/packages/jison-lex/dist/regexp-lexer-cjs-es5.js @@ -713,10 +713,10 @@ let yy=this.yy;let yyparser=yy.parser;let yylexer=yy.lexer;const OPTION_DOES_NOT this.$=yyvstack[yysp-1];this._$=yylstack[yysp-1];// END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break;case 1:/*! Production:: lex : init definitions rules_and_epilogue EOF */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];for(var key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: +{this.$=yyvstack[yysp-1];for(let key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: -for(key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){var asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: -if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +for(let key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){let asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: +if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;}case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if(yyvstack[yysp]){this.$={rules:yyvstack[yysp-1],moduleInclude:yyvstack[yysp]};}else{this.$={rules:yyvstack[yysp-1]};}break;case 3:/*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) @@ -777,7 +777,7 @@ yy.startConditions={};// hash table // fail. yy.__context_description__=['???CONTEXT???'];yy.pushContextDescription=function(str){yy.__context_description__.push(str);};yy.popContextDescription=function(){if(yy.__context_description__.length>1){yy.__context_description__.pop();}else{yyparser.yyError('__context_description__ stack depleted! Contact a developer!');}};yy.getContextDescription=function(){return yy.__context_description__[yy.__context_description__.length-1];};break;case 8:/*! Production:: definitions : definitions definition */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];if(yyvstack[yysp]){switch(yyvstack[yysp].type){case'macro':this.$.macros[yyvstack[yysp].name]=yyvstack[yysp].body;break;case'names':var condition_defs=yyvstack[yysp].names;for(var i=0,len=condition_defs.length;i=0){var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` +console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0){let marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -1088,7 +1088,7 @@ console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0 Technical error report: ${yyvstack[yysp].errStr} - `);}this.$=yyvstack[yysp-2];break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];}break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` \`${yy.__options_category_description__}\` statements must be placed in @@ -1147,14 +1147,14 @@ yyparser.yyError(rmCommonWS$1` this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 59:/*! Production:: rule : regex ACTION_START action ACTION_END */case 60:/*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION_CODE so that the action chunk test/compiler +{let srcCode=trimActionCode$1(yyvstack[yysp-1]);// 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. // @@ -1165,7 +1165,7 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION // By doing this, we simplify the token return replacement code replacement // process which will be applied to the parsed lexer before its code // will be generated by JISON. -if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} # NOTE that the arrow action automatically wraps the action code @@ -1174,7 +1174,7 @@ if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='retur Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule action arrow must be followed by a single JavaScript expression specifying the lexer token to produce, e.g.: @@ -1294,8 +1294,8 @@ yyparser.yyError(rmCommonWS$1` this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 73:/*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -this.$=yyvstack[yysp-2].map(function(el){var name=el[0];// Validate the given condition state: when it isn't known, print an error message +{// rewrite + accept star '*' as name + check if we allow empty list? +this.$=yyvstack[yysp-2].map(function(el){let name=el[0];// Validate the given condition state: when it isn't known, print an error message // accordingly: if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError(rmCommonWS$1` You specified an unknown lexer condition state '${name}'. @@ -1314,10 +1314,10 @@ if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError ${yylexer.prettyPrintRange(yylstack[yysp-2],yylstack[yysp-3],yylstack[yysp])} `);}return name;});// '<' '*' '>' // { $$ = ['*']; } -break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): +}break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$1` +{// rewrite + accept star '*' as name + check if we allow empty list? +let lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$1` Seems you did not correctly terminate the start condition set <${lst.join(',')},???> with a terminating '>' @@ -1327,9 +1327,9 @@ var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCom Technical error report: ${yyvstack[yysp].errStr} - `);break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// Detect if the regex ends with a pure (Unicode) word; +{// Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are // all valid 'words' for the 'easy keyword rules' option: @@ -1367,7 +1367,7 @@ this.$=this.$.replace(/\\\\/g,'.').replace(/"/g,'.').replace(/\\c[A-Z]/g,'.').re this.$=JSON.parse('"'+this.$+'"');}catch(ex){yyparser.warn('easy-keyword-rule FAIL on eval: ',ex);// make the next keyword test fail: this.$='.';}// a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: -var re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +let re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp];break;case 78:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) @@ -1429,17 +1429,17 @@ if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/ this.$=yyvstack[yysp];}else{this.$=yyvstack[yysp];}//yyparser.log("name expansion for: ", { name: $name_expansion, redux: $name_expansion.replace(/[{}]/g, ''), output: $$ }); break;case 111:/*! Production:: literal_string : STRING_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var src=yyvstack[yysp];var s=src.substring(1,src.length-1);var edge=src[0];this.$=encodeRegexLiteralStr(s,edge);break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +{let src=yyvstack[yysp];let s=src.substring(1,src.length-1);let edge=src[0];this.$=encodeRegexLiteralStr(s,edge);}break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +{let s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);}break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal behaviour under the given circumstances, i.e. parser context: +{// validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$1` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp]),yylstack[yysp-4])} - `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){var optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$1` + `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){let optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$1` You may not separate entries in a ${yy.__options_category_description__} statement using commas. Use whitespace instead, e.g.: @@ -1447,7 +1447,7 @@ if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyErro Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);}break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$1` @@ -1480,7 +1480,7 @@ yyparser.yyError(rmCommonWS$1` ${yyvstack[yysp].errStr} `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) -var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. Erroneous area: @@ -1488,14 +1488,14 @@ var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&O Technical error report: ${yyvstack[yysp].errStr} - `);break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: +{// validate that this is legal input under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES){this.$=mkIdentifier$1(yyvstack[yysp]);// check if the transformation is obvious & trivial to humans; // if not, report an error as we don't want confusion due to // typos and/or garbage input here producing something that // is usable from a machine perspective. -if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +if(!isLegalIdentifierInput$1(yyvstack[yysp])){let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -1503,10 +1503,10 @@ if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optiona Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}}else{this.$=yyvstack[yysp];}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}else{this.$=yyvstack[yysp];}}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: -if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +{// validate that this is legal input under the given circumstances, i.e. parser context: +if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -1514,7 +1514,7 @@ if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_fl Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=JSON5__default['default'].parse(yyvstack[yysp]);break;case 123:/*! Production:: option_value : OPTION_VALUE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) @@ -1522,12 +1522,12 @@ this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 125:/*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){let rv=checkActionBlock$1(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-1])} - `);}}this.$=srcCode;break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$=srcCode;}break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` There's an error in your lexer epilogue code block. @@ -1550,7 +1550,7 @@ yyparser.yyError(rmCommonWS$1` ${yyvstack[yysp].errStr} `);this.$='';break;case 130:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} Erroneous area: @@ -1558,9 +1558,9 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var `);}}// Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) // we append those protective double newlines right now, as the calling site // won't do it for us: -this.$='\n\n'+srcCode+'\n\n';break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): +this.$='\n\n'+srcCode+'\n\n';}break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` +{let start_marker=yyvstack[yysp-1].trim();yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -1568,14 +1568,14 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$='';break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);this.$='';}break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // these code chunks are very probably incomplete, hence compile-testing // for these should be deferred until we've collected the entire epilogue. this.$=yyvstack[yysp];break;case 134:/*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) -// check if there is only 1 unvalued options: 'path' -var lst=yyvstack[yysp-1];var len=lst.length;var path;if(len===1&&lst[0][1]===true){// `path`: +{// check if there is only 1 unvalued options: 'path' +let lst=yyvstack[yysp-1];let len=lst.length;let path;if(len===1&&lst[0][1]===true){// `path`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` You did not specify a legal file path for the '%include' statement, which must have the format: %include file_path @@ -1595,12 +1595,12 @@ path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` Technical error report: ${$error.errStr} `);}// **Aside**: And no, we don't support nested '%include'! -var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var srcCode=trimActionCode$1(fileContent);if(srcCode){var rv=checkActionBlock$1(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$1` +let fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});let srcCode=trimActionCode$1(fileContent);if(srcCode){let rv=checkActionBlock$1(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(this._$)} - `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';}break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` %include MUST be followed by a valid file path. @@ -2774,8 +2774,8 @@ yy_.yyerror(rmCommonWS` return 35;case 5:/*! Conditions:: action */ /*! Rule:: \/\/.* */yy.include_command_allowed=false;return 35;case 6:/*! Conditions:: action */ /*! Rule:: \| */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 7:/*! Conditions:: action */ /*! Rule:: %% */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 8:/*! Conditions:: action */ /*! Rule:: \/(?=\s) */return 35;// most probably a `/` divide operator. -case 9:/*! Conditions:: action */ /*! Rule:: \/.* */yy.include_command_allowed=false;var l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: -this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` +case 9:/*! Conditions:: action */ /*! Rule:: \/.* */{yy.include_command_allowed=false;let l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: +this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;}case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` too many closing curly braces in lexer rule action block. Note: the action code chunk may be too complex for jison to parse @@ -2795,16 +2795,16 @@ return 23;}case 18:/*! Conditions:: action */ /*! Rule:: $ */yy.include_co to help jison grok more or less complex action code chunks. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */{yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). -var marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: +let marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own, i.e. is not a rule action, %code // section, etc... -//var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); -//var precedingStr = this.matched.substr(-this.match.length - 1, 1); -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? -var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: +//let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); +//let precedingStr = this.matched.substr(-this.match.length - 1, 1); +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? +let endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: // we'd better make sure that end marker indeed does exist in the // remainder of the input! When it's not, we'll have the `action` // lexer state running past its due date as it'll then go and spit @@ -2814,7 +2814,7 @@ var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity c // Writing the wrong end marker is a common user mistake, we can // easily look ahead and check for it now and report a proper hint // to cover this failure mode in a more helpful manner. -var remaining=this.lookAhead();var prevEnd=0;var endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, +let remaining=this.lookAhead();let prevEnd=0;let endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd=endMarkerIndex+endMarker.length;continue;}if(endMarkerIndex<0){yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the @@ -2825,7 +2825,7 @@ if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd= `+this.prettyPrintRange(yy_.yylloc));return 24;}break;}// Allow the start marker to be re-matched by the generated lexer rule regex: this.unput(marker);// Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: yy_.yytext=marker;// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); +if(atSOL){return 22;}return 25;}case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */{yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); this.pushState('action');// Do a bit of magic that's useful for the parser when we // call `trimActionCode()` in there to perform a bit of // rough initial action code chunk cleanup: @@ -2850,27 +2850,27 @@ this.pushState('action');// Do a bit of magic that's useful for the parser when // follow after `trimActionCode()` has passed once we // get to the parser productions which process this // upcoming action code block. -var la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser -}return 25;case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse +let la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser +}return 25;}case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);return 25;case 32:/*! Conditions:: options */ /*! Rule:: > */this.popState();this.unput(yy_.yytext);return 21;case 35:/*! Conditions:: options */ /*! Rule:: <{ID}> */yy_.yytext=this.matches[1];return'TOKEN_TYPE';case 37:/*! Conditions:: options */ /*! Rule:: {BR}{WS}+(?=\S) */ /* ignore */break;case 38:/*! Conditions:: options */ /*! Rule:: {BR} */this.popState();this.unput(yy_.yytext);return 21;case 39:/*! Conditions:: options */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 40:/*! Conditions:: INITIAL */ /*! Rule:: {ID} */this.pushState('macro');return 19;case 41:/*! Conditions:: macro */ /*! Rule:: {BR}+ */this.popState();this.unput(yy_.yytext);return 20;case 42:/*! Conditions:: macro */ /*! Rule:: $ */this.popState();this.unput(yy_.yytext);return 20;case 43:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {BR}+ */ /* skip newlines */break;case 44:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 48:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {ANY_LITERAL_CHAR}+ */ // accept any non-regex, non-lex, non-string-delim, // non-escape-starter, non-space character as-is return 50;case 49:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \[ */this.pushState('set');return 45;case 64:/*! Conditions:: rules macro INITIAL */ /*! Rule:: < */this.pushState('options');return 3;case 66:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/! */return 41;// treated as `(?!atom)` case 67:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/ */return 13;// treated as `(?=atom)` -case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */var m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A -var v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 -var v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A -var v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[5],16);yy_.yytext=v;}return 43;case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: +case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */{let m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A +let v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 +let v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A +let v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[5],16);yy_.yytext=v;}return 43;}case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */{yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own. -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` +if(atSOL){return 22;}return 25;}case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` ignoring unsupported lexer option ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -2903,22 +2903,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` unterminated string constant in %options entry. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 101:/*! Conditions:: * */ /*! Rule:: ' */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 101:/*! Conditions:: * */ /*! Rule:: ' */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 102:/*! Conditions:: * */ /*! Rule:: ` */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 102:/*! Conditions:: * */ /*! Rule:: ` */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 103:/*! Conditions:: macro rules */ /*! Rule:: . */ /* b0rk on bad characters */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 103:/*! Conditions:: macro rules */ /*! Rule:: . */{/* b0rk on bad characters */let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -2930,7 +2930,7 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` regex expression here in jison-lex ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 2;}case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` unsupported lexer input: ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -2944,22 +2944,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` while lexing in ${dquote(this.topState())} state. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};var rmCommonWS=helpers.rmCommonWS;var dquote=helpers.dquote;var scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a + `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};const rmCommonWS=helpers.rmCommonWS;const dquote=helpers.dquote;const scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a // lexer rule to match when the need arrises: lexer.setupDelimitedActionChunkLexerRegex=function lexer__setupDelimitedActionChunkLexerRegex(marker){// Special: when we encounter `{` as the start of the action code block, // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! -var doNotPatch=marker==='{';var action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! +let doNotPatch=marker==='{';let action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! // // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) -var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. +let spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps // speed up those activities a tiny bit. -spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regexes;var len=spec.__rule_count;var rules=spec.rules;var i;var action_chunk_regex;// Must we still locate the rule to patch or have we done +spec=this.__currentRuleSet__=this._currentRules();}let regexes=spec.__rule_regexes;let len=spec.__rule_count;let rules=spec.rules;let i;let action_chunk_regex;// Must we still locate the rule to patch or have we done // that already during a previous encounter? // // WARNING: our cache/patch must live beyond the current lexer+parser invocation: @@ -2972,10 +2972,10 @@ spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regex if(!spec.__action_chunk_rule_idx){// **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! -var orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';var orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. +let orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';let orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! -for(i=1;i<=len;i++){var rule_re=regexes[i];var re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); +for(i=1;i<=len;i++){let rule_re=regexes[i];let re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if(re_str===orig_re_str1||re_str===orig_re_str2){spec.__action_chunk_rule_idx=i;break;}}if(!spec.__action_chunk_rule_idx){//console.error('ruleset dump:', spec); throw new Error('INTERNAL DEV ERROR: cannot locate %{...%} rule regex!');}// As we haven't initialized yet, we're sure the rule cache doesn't exist either. // Make it happen: @@ -2985,7 +2985,7 @@ spec.__cached_action_chunk_rule={};// set up empty cache action_chunk_regex=spec.__cached_action_chunk_rule[marker];if(!action_chunk_regex){action_chunk_regex=spec.__cached_action_chunk_rule[marker]=new RegExp('^(?:'+marker.replace(/\{/g,'\\{')+'([^]*?)'+action_end_marker.replace(/\}/g,'\\}')+'(?!\\}))');//console.warn('encode new action block regex:', action_chunk_regex); }//console.error('new ACTION REGEX:', { i, action_chunk_regex }); // and patch the lexer regex table for the current lexer condition state: -regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser.lexer=lexer;var rmCommonWS$1=helpers.rmCommonWS;var checkActionBlock$1=helpers.checkActionBlock;var mkIdentifier$1=helpers.mkIdentifier;var isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;var trimActionCode$1=helpers.trimActionCode;// see also: +regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser.lexer=lexer;const rmCommonWS$1=helpers.rmCommonWS;const checkActionBlock$1=helpers.checkActionBlock;const mkIdentifier$1=helpers.mkIdentifier;const isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;const trimActionCode$1=helpers.trimActionCode;// see also: // - https://en.wikipedia.org/wiki/C0_and_C1_control_codes // - https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-escapes-in-regular-expressions // - https://kangax.github.io/compat-table/es6/#test-RegExp_y_and_u_flags @@ -2997,27 +2997,27 @@ const charCvtTable={// "\a": "\x07", "\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v"};const escCvtTable={"a":"\\x07","e":"\\x1B","b":"\\x08","f":"\\f","n":"\\n","r":"\\r","t":"\\t","v":"\\v"};const codeCvtTable={12:"\\f",10:"\\n",13:"\\r",9:"\\t",11:"\\v"};// Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){var rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); -for(var i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead +const codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){let rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); +for(let i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. -var m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s +let m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s rv+='\\\\'+m[1];i+=m[1].length-1;continue;}if(m[2]){// [2]: regex special characters, which occur in a literal string: `\[` --> \\\[ rv+='\\\\\\'+m[2];i+=m[2].length-1;continue;}if(m[3]){// [3]: special escape characters, which occur in a literal string: `\a` --> BELL rv+=escCvtTable[m[3]];i+=m[3].length-1;continue;}if(m[4]){// [4]: octal char: `\012` --> \x0A -var v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 -var v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A -var v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: +let v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 +let v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A +let v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: rv+='\\\\';i--;continue;default:// escape regex operators: -var pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}var cc=charCvtTable[c];if(cc){rv+=cc;continue;}var cc=c.charCodeAt(0);if(cc<32){var rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); +let pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}let cc=charCvtTable[c];if(cc){rv+=cc;continue;}cc=c.charCodeAt(0);if(cc<32){let rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); return s;}// convert string value to number or boolean value, when possible // (and when this is more or less obviously the intent) // otherwise produce the string itself as value. function parseValue(v){if(v==='false'){return false;}if(v==='true'){return true;}// http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) -if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser.warn=function p_warn(){console.warn.apply(console,arguments);};parser.log=function p_log(){console.log.apply(console,arguments);};parser.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse:',arguments);};parser.yy.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse YY:',arguments);};parser.yy.post_lex=function p_lex(){if(parser.yydebug)parser.log('post_lex:',arguments);};function Parser(){this.yy={};}Parser.prototype=parser;parser.Parser=Parser;function yyparse(){return parser.parse.apply(parser,arguments);}var lexParser={parser,Parser,parse:yyparse};// +if(v&&!isNaN(v)){let rv=+v;if(isFinite(rv)){return rv;}}return v;}parser.warn=function p_warn(){console.warn.apply(console,arguments);};parser.log=function p_log(){console.log.apply(console,arguments);};parser.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse:',arguments);};parser.yy.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse YY:',arguments);};parser.yy.post_lex=function p_lex(){if(parser.yydebug)parser.log('post_lex:',arguments);};function Parser(){this.yy={};}Parser.prototype=parser;parser.Parser=Parser;function yyparse(){return parser.parse.apply(parser,arguments);}var lexParser={parser,Parser,parse:yyparse};// const XREGEXP_UNICODE_ESCAPE_RE=/^\{[A-Za-z0-9 \-\._]+\}/;// Matches the XRegExp Unicode escape braced part, e.g. `{Number}` const CHR_RE=/^(?:[^\\]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})/;const SET_PART_RE=/^(?:[^\\\]]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;const NOTHING_SPECIAL_RE=/^(?:[^\\\[\]\(\)\|^\{\}]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;const SET_IS_SINGLE_PCODE_RE=/^\\[dDwWsS]$|^\\p\{[A-Za-z0-9 \-\._]+\}$/;const UNICODE_BASE_PLANE_MAX_CP=65535;// The expanded regex sets which are equivalent to the given `\\{c}` escapes: // @@ -3320,7 +3320,10 @@ action=helpers.printFunctionSourceCodeContainer(action).code;}action=action.repl // which would then cause havoc when our action code analysis (using regexes or otherwise) was 'too simple' // to catch these culprits; hence we resort and stick with the most fundamental approach here: // always append `break;` even when it would be obvious to a human that such would be 'unreachable code'. -let match_nr=/^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim());if(match_nr){simple_rule_count++;caseHelper.push([].concat(code,i,':',match_nr[1]).join(' ').replace(/[\n]/g,'\n '));}else{regular_rule_count++;routingCode.push([].concat('case',i,':',code,action,'\nbreak;').join(' '));}}if(simple_rule_count){routingCode.push('default:');routingCode.push(' return this.simpleCaseActionClusters[yyrulenumber];');}routingCode.push('}');// only inject the big switch/case chunk when there's any `switch` or `default` branch to switch to: +let match_nr=/^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim());if(match_nr){simple_rule_count++;caseHelper.push([].concat(code,i,':',match_nr[1]).join(' ').replace(/[\n]/g,'\n '));}else{regular_rule_count++;// If action includes the keyword `let` or `const`, then it's ES6 code +// which must be scoped to prevent collisions with other action code chunks +// in the same large generated switch/case statement: +if(/\blet\b/.test(action)||/\bconst\b/.test(action)){action='{\n'+action+'\n}';}routingCode.push([].concat('case',i,':',code,action,'\nbreak;').join(' '));}}if(simple_rule_count){routingCode.push('default:');routingCode.push(' return this.simpleCaseActionClusters[yyrulenumber];');}routingCode.push('}');// only inject the big switch/case chunk when there's any `switch` or `default` branch to switch to: if(simple_rule_count+regular_rule_count>0){actions.push.apply(actions,routingCode);}else{actions.push('/* no rules ==> no rule SWITCH! */');}return{rules:newRules,// array listing only the lexer spec regexes macros:macros,regular_rule_count:regular_rule_count,simple_rule_count:simple_rule_count};}// expand all macros (with maybe one exception) in the given regex: the macros may exist inside `[...]` regex sets or // elsewhere, which requires two different treatments to expand these macros. diff --git a/packages/jison-lex/dist/regexp-lexer-cjs.js b/packages/jison-lex/dist/regexp-lexer-cjs.js index c19d64f21..7b1e1f8d0 100644 --- a/packages/jison-lex/dist/regexp-lexer-cjs.js +++ b/packages/jison-lex/dist/regexp-lexer-cjs.js @@ -2560,20 +2560,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2583,6 +2584,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2732,6 +2734,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2740,9 +2743,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -2789,6 +2792,7 @@ case 8: break; } } + } break; case 9: @@ -2873,8 +2877,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -2882,6 +2887,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -2912,8 +2918,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -2921,6 +2928,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -2951,9 +2959,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -2965,6 +2974,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -2990,8 +3000,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3012,8 +3020,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3028,6 +3037,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3038,11 +3048,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3087,10 +3099,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3119,6 +3132,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3152,10 +3166,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3177,8 +3192,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3194,6 +3209,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3205,9 +3221,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3221,6 +3238,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3433,9 +3451,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3447,6 +3466,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3470,8 +3490,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3482,6 +3502,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3492,13 +3513,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3528,6 +3550,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3693,8 +3716,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3704,6 +3728,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3714,7 +3739,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3732,7 +3758,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3747,6 +3773,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3992,9 +4019,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4022,6 +4050,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4033,8 +4062,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4049,6 +4079,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4059,6 +4090,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4113,13 +4145,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4407,10 +4440,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4421,8 +4456,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4433,6 +4470,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4443,7 +4481,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4460,6 +4498,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4555,7 +4594,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4568,6 +4608,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4578,6 +4619,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -4586,7 +4628,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4603,6 +4645,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4613,11 +4656,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4631,6 +4675,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4674,9 +4719,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4687,6 +4733,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4738,9 +4785,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4754,6 +4802,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4764,8 +4813,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4776,6 +4825,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -4799,10 +4849,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -4831,11 +4882,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -4847,6 +4898,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -9996,21 +10048,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10104,55 +10157,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10160,24 +10213,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10205,44 +10259,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10367,38 +10422,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10438,29 +10494,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10564,49 +10621,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10620,7 +10684,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11197,9 +11262,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11208,9 +11273,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11218,7 +11283,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11228,11 +11293,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11248,15 +11313,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11316,11 +11381,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$1 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$1 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11361,11 +11426,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11375,7 +11440,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11384,10 +11449,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11397,7 +11462,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11410,7 +11475,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11432,35 +11497,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11474,19 +11539,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11517,7 +11582,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -12903,6 +12968,12 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } diff --git a/packages/jison-lex/dist/regexp-lexer-es6.js b/packages/jison-lex/dist/regexp-lexer-es6.js index b7a7507ae..ce634d6ff 100644 --- a/packages/jison-lex/dist/regexp-lexer-es6.js +++ b/packages/jison-lex/dist/regexp-lexer-es6.js @@ -2548,20 +2548,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2571,6 +2572,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2720,6 +2722,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2728,9 +2731,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -2777,6 +2780,7 @@ case 8: break; } } + } break; case 9: @@ -2861,8 +2865,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -2870,6 +2875,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -2900,8 +2906,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -2909,6 +2916,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -2939,9 +2947,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -2953,6 +2962,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -2978,8 +2988,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3000,8 +3008,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3016,6 +3025,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3026,11 +3036,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3075,10 +3087,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3107,6 +3120,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3140,10 +3154,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3165,8 +3180,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3182,6 +3197,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3193,9 +3209,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3209,6 +3226,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3421,9 +3439,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3435,6 +3454,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3458,8 +3478,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3470,6 +3490,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3480,13 +3501,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3516,6 +3538,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3681,8 +3704,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3692,6 +3716,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3702,7 +3727,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3720,7 +3746,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3735,6 +3761,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3980,9 +4007,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4010,6 +4038,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4021,8 +4050,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4037,6 +4067,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4047,6 +4078,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4101,13 +4133,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp('\\w[\\w\\d]*$'); + let re = new XRegExp('\\w[\\w\\d]*$'); if (XRegExp.match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4395,10 +4428,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4409,8 +4444,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4421,6 +4458,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4431,7 +4469,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4448,6 +4486,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4543,7 +4582,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4556,6 +4596,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4566,6 +4607,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -4574,7 +4616,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4591,6 +4633,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4601,11 +4644,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4619,6 +4663,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4662,9 +4707,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4675,6 +4721,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4726,9 +4773,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4742,6 +4790,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4752,8 +4801,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4764,6 +4813,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -4787,10 +4837,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -4819,11 +4870,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -4835,6 +4886,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -9984,21 +10036,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10092,55 +10145,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10148,24 +10201,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10193,44 +10247,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10355,38 +10410,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10426,29 +10482,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10552,49 +10609,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10608,7 +10672,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11185,9 +11250,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11196,9 +11261,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11206,7 +11271,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11216,11 +11281,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11236,15 +11301,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11304,11 +11369,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$1 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$1 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11349,11 +11414,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11363,7 +11428,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11372,10 +11437,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11385,7 +11450,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11398,7 +11463,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11420,35 +11485,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11462,19 +11527,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11505,7 +11570,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -12891,6 +12956,12 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } diff --git a/packages/jison-lex/dist/regexp-lexer-umd-es5.js b/packages/jison-lex/dist/regexp-lexer-umd-es5.js index a0d5e333e..22c804f68 100644 --- a/packages/jison-lex/dist/regexp-lexer-umd-es5.js +++ b/packages/jison-lex/dist/regexp-lexer-umd-es5.js @@ -713,10 +713,10 @@ let yy=this.yy;let yyparser=yy.parser;let yylexer=yy.lexer;const OPTION_DOES_NOT this.$=yyvstack[yysp-1];this._$=yylstack[yysp-1];// END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break;case 1:/*! Production:: lex : init definitions rules_and_epilogue EOF */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];for(var key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: +{this.$=yyvstack[yysp-1];for(let key in yyvstack[yysp-2]){this.$[key]=yyvstack[yysp-2][key];}// if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: -for(key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){var asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: -if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +for(let key in yy.options){this.$.options=yy.options;break;}if(yy.actionInclude){let asrc=yy.actionInclude.join('\n\n');// Only a non-empty action code chunk should actually make it through: +if(asrc.trim()!==''){this.$.actionInclude=asrc;}}delete yy.options;delete yy.actionInclude;return this.$;}case 2:/*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if(yyvstack[yysp]){this.$={rules:yyvstack[yysp-1],moduleInclude:yyvstack[yysp]};}else{this.$={rules:yyvstack[yysp-1]};}break;case 3:/*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) @@ -777,7 +777,7 @@ yy.startConditions={};// hash table // fail. yy.__context_description__=['???CONTEXT???'];yy.pushContextDescription=function(str){yy.__context_description__.push(str);};yy.popContextDescription=function(){if(yy.__context_description__.length>1){yy.__context_description__.pop();}else{yyparser.yyError('__context_description__ stack depleted! Contact a developer!');}};yy.getContextDescription=function(){return yy.__context_description__[yy.__context_description__.length-1];};break;case 8:/*! Production:: definitions : definitions definition */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1];if(yyvstack[yysp]){switch(yyvstack[yysp].type){case'macro':this.$.macros[yyvstack[yysp].name]=yyvstack[yysp].body;break;case'names':var condition_defs=yyvstack[yysp].names;for(var i=0,len=condition_defs.length;i=0){var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` +console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0){let marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -1088,7 +1088,7 @@ console.error("*** error! marker:",start_marker);if(start_marker.indexOf('{')>=0 Technical error report: ${yyvstack[yysp].errStr} - `);}this.$=yyvstack[yysp-2];break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];}break;case 45:/*! Production:: rules : rules start_inclusive_keyword */case 46:/*! Production:: rules : rules start_exclusive_keyword */case 47:/*! Production:: rules : rules option_keyword */case 48:/*! Production:: rules : rules UNKNOWN_DECL */case 49:/*! Production:: rules : rules import_keyword */case 50:/*! Production:: rules : rules init_code_keyword */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` \`${yy.__options_category_description__}\` statements must be placed in @@ -1147,14 +1147,14 @@ yyparser.yyError(rmCommonWS$1` this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 59:/*! Production:: rule : regex ACTION_START action ACTION_END */case 60:/*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 61:/*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION_CODE so that the action chunk test/compiler +{let srcCode=trimActionCode$1(yyvstack[yysp-1]);// 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. // @@ -1165,7 +1165,7 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1]);// add braces around ARROW_ACTION // By doing this, we simplify the token return replacement code replacement // process which will be applied to the parsed lexer before its code // will be generated by JISON. -if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='return ('+srcCode+'\n)';}let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} # NOTE that the arrow action automatically wraps the action code @@ -1174,7 +1174,7 @@ if(/^[^\r\n;\/]+$/.test(srcCode)){srcCode='return '+srcCode;}else{srcCode='retur Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-3])} - `);}this.$=[yyvstack[yysp-3],srcCode];break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=[yyvstack[yysp-3],srcCode];}break;case 62:/*! Production:: rule : regex ARROW_ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule action arrow must be followed by a single JavaScript expression specifying the lexer token to produce, e.g.: @@ -1294,8 +1294,8 @@ yyparser.yyError(rmCommonWS$1` this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 73:/*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -this.$=yyvstack[yysp-2].map(function(el){var name=el[0];// Validate the given condition state: when it isn't known, print an error message +{// rewrite + accept star '*' as name + check if we allow empty list? +this.$=yyvstack[yysp-2].map(function(el){let name=el[0];// Validate the given condition state: when it isn't known, print an error message // accordingly: if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError(rmCommonWS$1` You specified an unknown lexer condition state '${name}'. @@ -1314,10 +1314,10 @@ if(name!=='*'&&name!=='INITIAL'&&!(name in yy.startConditions)){yyparser.yyError ${yylexer.prettyPrintRange(yylstack[yysp-2],yylstack[yysp-3],yylstack[yysp])} `);}return name;});// '<' '*' '>' // { $$ = ['*']; } -break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): +}break;case 74:/*! Production:: start_conditions : start_conditions_marker option_list error */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-2];this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) -// rewrite + accept star '*' as name + check if we allow empty list? -var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$1` +{// rewrite + accept star '*' as name + check if we allow empty list? +let lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCommonWS$1` Seems you did not correctly terminate the start condition set <${lst.join(',')},???> with a terminating '>' @@ -1327,9 +1327,9 @@ var lst=yyvstack[yysp-1].map(function(el){return el[0];});yyparser.yyError(rmCom Technical error report: ${yyvstack[yysp].errStr} - `);break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 75:/*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// Detect if the regex ends with a pure (Unicode) word; +{// Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are // all valid 'words' for the 'easy keyword rules' option: @@ -1367,7 +1367,7 @@ this.$=this.$.replace(/\\\\/g,'.').replace(/"/g,'.').replace(/\\c[A-Z]/g,'.').re this.$=JSON.parse('"'+this.$+'"');}catch(ex){yyparser.warn('easy-keyword-rule FAIL on eval: ',ex);// make the next keyword test fail: this.$='.';}// a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: -var re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +let re=new XRegExp__default['default']('\\w[\\w\\d]*$');if(XRegExp__default['default'].match(this.$,re)){this.$=yyvstack[yysp]+"\\b";}else{this.$=yyvstack[yysp];}}}break;case 76:/*! Production:: regex_list : nonempty_regex_list */case 82:/*! Production:: nonempty_regex_list : regex_concat */case 84:/*! Production:: regex_concat : regex_base */case 103:/*! Production:: name_expansion : NAME_BRACE */case 110:/*! Production:: range_regex : RANGE_REGEX */case 129:/*! Production:: epilogue_chunks : epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=yyvstack[yysp];break;case 78:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) @@ -1429,17 +1429,17 @@ if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/ this.$=yyvstack[yysp];}else{this.$=yyvstack[yysp];}//yyparser.log("name expansion for: ", { name: $name_expansion, redux: $name_expansion.replace(/[{}]/g, ''), output: $$ }); break;case 111:/*! Production:: literal_string : STRING_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var src=yyvstack[yysp];var s=src.substring(1,src.length-1);var edge=src[0];this.$=encodeRegexLiteralStr(s,edge);break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): +{let src=yyvstack[yysp];let s=src.substring(1,src.length-1);let edge=src[0];this.$=encodeRegexLiteralStr(s,edge);}break;case 112:/*! Production:: literal_string : CHARACTER_LIT */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -var s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): +{let s=yyvstack[yysp];this.$=encodeRegexLiteralStr(s);}break;case 113:/*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal behaviour under the given circumstances, i.e. parser context: +{// validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$1` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp]),yylstack[yysp-4])} - `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){var optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$1` + `);}if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS){let optlist=yyvstack[yysp-2].map(function(opt){return opt[0];});optlist.push(yyvstack[yysp][0]);yyparser.yyError(rmCommonWS$1` You may not separate entries in a ${yy.__options_category_description__} statement using commas. Use whitespace instead, e.g.: @@ -1447,7 +1447,7 @@ if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyErro Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp-1],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): + `);}this.$=yyvstack[yysp-2];this.$.push(yyvstack[yysp]);}break;case 114:/*! Production:: option_list : option_list option */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // validate that this is legal behaviour under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS){yyparser.yyError(rmCommonWS$1` @@ -1480,7 +1480,7 @@ yyparser.yyError(rmCommonWS$1` ${yyvstack[yysp].errStr} `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) -var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. Erroneous area: @@ -1488,14 +1488,14 @@ var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&O Technical error report: ${yyvstack[yysp].errStr} - `);break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}break;case 120:/*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: +{// validate that this is legal input under the given circumstances, i.e. parser context: if(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES){this.$=mkIdentifier$1(yyvstack[yysp]);// check if the transformation is obvious & trivial to humans; // if not, report an error as we don't want confusion due to // typos and/or garbage input here producing something that // is usable from a machine perspective. -if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +if(!isLegalIdentifierInput$1(yyvstack[yysp])){let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -1503,10 +1503,10 @@ if(!isLegalIdentifierInput$1(yyvstack[yysp])){var with_value_msg=' (with optiona Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}}else{this.$=yyvstack[yysp];}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}else{this.$=yyvstack[yysp];}}break;case 121:/*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) -// validate that this is legal input under the given circumstances, i.e. parser context: -if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{var with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` +{// validate that this is legal input under the given circumstances, i.e. parser context: +if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_flags__&OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME){this.$=yyvstack[yysp];}else{let with_value_msg=' (with optional value assignment)';if(yy.__options_flags__&OPTION_DOES_NOT_ACCEPT_VALUE){with_value_msg='';}yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -1514,7 +1514,7 @@ if(!(yy.__options_flags__&OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES)||yy.__options_fl Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-2])} - `);}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);}}break;case 122:/*! Production:: option_value : OPTION_STRING */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$=JSON5__default['default'].parse(yyvstack[yysp]);break;case 123:/*! Production:: option_value : OPTION_VALUE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) @@ -1522,12 +1522,12 @@ this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$='';break;case 125:/*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp]);if(srcCode){let rv=checkActionBlock$1(srcCode,yylstack[yysp],yy);if(rv){yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-1])} - `);}}this.$=srcCode;break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$=srcCode;}break;case 126:/*! Production:: epilogue : start_epilogue_marker error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` There's an error in your lexer epilogue code block. @@ -1550,7 +1550,7 @@ yyparser.yyError(rmCommonWS$1` ${yyvstack[yysp].errStr} `);this.$='';break;case 130:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) -var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` +{let srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){let rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} Erroneous area: @@ -1558,9 +1558,9 @@ var srcCode=trimActionCode$1(yyvstack[yysp-1],yyvstack[yysp-2]);if(srcCode){var `);}}// Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) // we append those protective double newlines right now, as the calling site // won't do it for us: -this.$='\n\n'+srcCode+'\n\n';break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): +this.$='\n\n'+srcCode+'\n\n';}break;case 131:/*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) -var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or similar, such as '+start_marker:'';yyparser.yyError(rmCommonWS$1` +{let start_marker=yyvstack[yysp-1].trim();yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -1568,14 +1568,14 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$='';break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): + `);this.$='';}break;case 133:/*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // these code chunks are very probably incomplete, hence compile-testing // for these should be deferred until we've collected the entire epilogue. this.$=yyvstack[yysp];break;case 134:/*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) -// check if there is only 1 unvalued options: 'path' -var lst=yyvstack[yysp-1];var len=lst.length;var path;if(len===1&&lst[0][1]===true){// `path`: +{// check if there is only 1 unvalued options: 'path' +let lst=yyvstack[yysp-1];let len=lst.length;let path;if(len===1&&lst[0][1]===true){// `path`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` You did not specify a legal file path for the '%include' statement, which must have the format: %include file_path @@ -1595,12 +1595,12 @@ path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` Technical error report: ${$error.errStr} `);}// **Aside**: And no, we don't support nested '%include'! -var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var srcCode=trimActionCode$1(fileContent);if(srcCode){var rv=checkActionBlock$1(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$1` +let fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});let srcCode=trimActionCode$1(fileContent);if(srcCode){let rv=checkActionBlock$1(srcCode,this._$,yy);if(rv){yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(this._$)} - `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): + `);}}this.$='\n// Included by Jison: '+path+':\n\n'+srcCode+'\n\n// End Of Include by Jison: '+path+'\n\n';}break;case 135:/*! Production:: include_macro_code : include_keyword error */ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-): this.$=yyvstack[yysp-1];this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` %include MUST be followed by a valid file path. @@ -2774,8 +2774,8 @@ yy_.yyerror(rmCommonWS` return 35;case 5:/*! Conditions:: action */ /*! Rule:: \/\/.* */yy.include_command_allowed=false;return 35;case 6:/*! Conditions:: action */ /*! Rule:: \| */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 7:/*! Conditions:: action */ /*! Rule:: %% */if(yy.depth===0){this.popState();this.unput(yy_.yytext);// yy_.yytext = ''; --- ommitted as this is the side-effect of .unput(yy_.yytext) already! return 23;}else{return 35;}case 8:/*! Conditions:: action */ /*! Rule:: \/(?=\s) */return 35;// most probably a `/` divide operator. -case 9:/*! Conditions:: action */ /*! Rule:: \/.* */yy.include_command_allowed=false;var l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: -this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` +case 9:/*! Conditions:: action */ /*! Rule:: \/.* */{yy.include_command_allowed=false;let l=scanRegExp(yy_.yytext);if(l>0){this.unput(yy_.yytext.substring(l));yy_.yytext=yy_.yytext.substring(0,l);}else{// assume it's a division operator: +this.unput(yy_.yytext.substring(1));yy_.yytext=yy_.yytext[0];}return 35;}case 10:/*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */yy.include_command_allowed=false;return 35;case 11:/*! Conditions:: action */ /*! Rule:: [^/"'`%\{\}\/{BR}]+ */yy.include_command_allowed=false;return 35;case 12:/*! Conditions:: action */ /*! Rule:: % */yy.include_command_allowed=false;return 35;case 13:/*! Conditions:: action */ /*! Rule:: \{ */yy.depth++;yy.include_command_allowed=false;return 35;case 14:/*! Conditions:: action */ /*! Rule:: \} */yy.include_command_allowed=false;if(yy.depth<=0){yy_.yyerror(rmCommonWS` too many closing curly braces in lexer rule action block. Note: the action code chunk may be too complex for jison to parse @@ -2795,16 +2795,16 @@ return 23;}case 18:/*! Conditions:: action */ /*! Rule:: $ */yy.include_co to help jison grok more or less complex action code chunks. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + `+this.prettyPrintRange(yy_.yylloc));return 37;}this.popState();yy_.yytext='';return 23;case 19:/*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */{yy.depth=0;yy.include_command_allowed=false;this.pushState('action');// keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). -var marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: +let marker=yy_.yytext;// check whether this `%{` marker was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own, i.e. is not a rule action, %code // section, etc... -//var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); -//var precedingStr = this.matched.substr(-this.match.length - 1, 1); -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? -var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: +//let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); +//let precedingStr = this.matched.substr(-this.match.length - 1, 1); +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';// Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? +let endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity check for better error reporting: // we'd better make sure that end marker indeed does exist in the // remainder of the input! When it's not, we'll have the `action` // lexer state running past its due date as it'll then go and spit @@ -2814,7 +2814,7 @@ var endMarker=this.setupDelimitedActionChunkLexerRegex(marker);// Early sanity c // Writing the wrong end marker is a common user mistake, we can // easily look ahead and check for it now and report a proper hint // to cover this failure mode in a more helpful manner. -var remaining=this.lookAhead();var prevEnd=0;var endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, +let remaining=this.lookAhead();let prevEnd=0;let endMarkerIndex;for(;;){endMarkerIndex=remaining.indexOf(endMarker,prevEnd);// check for both simple non-existence *and* non-match due to trailing braces, // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd=endMarkerIndex+endMarker.length;continue;}if(endMarkerIndex<0){yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the @@ -2825,7 +2825,7 @@ if(endMarkerIndex>=0&&remaining[endMarkerIndex+endMarker.length]==='}'){prevEnd= `+this.prettyPrintRange(yy_.yylloc));return 24;}break;}// Allow the start marker to be re-matched by the generated lexer rule regex: this.unput(marker);// Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: yy_.yytext=marker;// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); +if(atSOL){return 22;}return 25;}case 20:/*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 21:/*! Conditions:: rules macro INITIAL */ /*! Rule:: → */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 22:/*! Conditions:: rules macro INITIAL */ /*! Rule:: => */yy.depth=0;yy.include_command_allowed=false;this.pushState('action');return 34;case 23:/*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */{yy.depth=0;yy.include_command_allowed=true;//console.error('*** ACTION start @ 355:', yy_.yytext); this.pushState('action');// Do a bit of magic that's useful for the parser when we // call `trimActionCode()` in there to perform a bit of // rough initial action code chunk cleanup: @@ -2850,27 +2850,27 @@ this.pushState('action');// Do a bit of magic that's useful for the parser when // follow after `trimActionCode()` has passed once we // get to the parser productions which process this // upcoming action code block. -var la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser -}return 25;case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse +let la=this.lookAhead();if(la[0]==='{'){yy_.yytext='{';// hint the parser +}return 25;}case 24:/*! Conditions:: rules */ /*! Rule:: %% */this.popState();this.pushState('code');return 33;case 25:/*! Conditions:: rules */ /*! Rule:: $ */this.popState();this.pushState('code');return 33;case 30:/*! Conditions:: options */ /*! Rule:: %%|\||; */this.popState();this.unput(yy_.yytext);return 21;case 31:/*! Conditions:: options */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);return 25;case 32:/*! Conditions:: options */ /*! Rule:: > */this.popState();this.unput(yy_.yytext);return 21;case 35:/*! Conditions:: options */ /*! Rule:: <{ID}> */yy_.yytext=this.matches[1];return'TOKEN_TYPE';case 37:/*! Conditions:: options */ /*! Rule:: {BR}{WS}+(?=\S) */ /* ignore */break;case 38:/*! Conditions:: options */ /*! Rule:: {BR} */this.popState();this.unput(yy_.yytext);return 21;case 39:/*! Conditions:: options */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 40:/*! Conditions:: INITIAL */ /*! Rule:: {ID} */this.pushState('macro');return 19;case 41:/*! Conditions:: macro */ /*! Rule:: {BR}+ */this.popState();this.unput(yy_.yytext);return 20;case 42:/*! Conditions:: macro */ /*! Rule:: $ */this.popState();this.unput(yy_.yytext);return 20;case 43:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {BR}+ */ /* skip newlines */break;case 44:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {WS}+ */ /* skip whitespace */break;case 48:/*! Conditions:: rules macro INITIAL */ /*! Rule:: {ANY_LITERAL_CHAR}+ */ // accept any non-regex, non-lex, non-string-delim, // non-escape-starter, non-space character as-is return 50;case 49:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \[ */this.pushState('set');return 45;case 64:/*! Conditions:: rules macro INITIAL */ /*! Rule:: < */this.pushState('options');return 3;case 66:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/! */return 41;// treated as `(?!atom)` case 67:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \/ */return 13;// treated as `(?=atom)` -case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */var m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A -var v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 -var v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A -var v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[5],16);yy_.yytext=v;}return 43;case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: +case 69:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */{let m=this.matches;yy_.yytext=NaN;if(m[1]){// [1]: octal char: `\012` --> \x0A +let v=parseInt(m[1],8);yy_.yytext=v;}else if(m[2]){// [2]: CONTROL char: `\cA` --> \u0001 +let v=m[2].charCodeAt(0)-64;yy_.yytext=v;}else if(m[3]){// [3]: hex char: `\x41` --> A +let v=parseInt(m[3],16);yy_.yytext=v;}else if(m[4]){// [4]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[4],16);yy_.yytext=v;}else if(m[5]){// [5]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[5],16);yy_.yytext=v;}return 43;}case 70:/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */yy_.yytext=yy_.yytext.substring(1);return 50;case 73:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %option[s]? */this.pushState('options');return 27;case 74:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %s\b */this.pushState('options');return 31;case 75:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %x\b */this.pushState('options');return 32;case 76:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %code\b */this.pushState('options');return 29;case 77:/*! Conditions:: rules macro INITIAL */ /*! Rule:: %import\b */this.pushState('options');return 28;case 80:/*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */{yy.depth=0;yy.include_command_allowed=true;// check whether this `%include` command was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own. -var precedingStr=this.matched[this.matched.length-this.match.length-1];var atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse +let precedingStr=this.matched[this.matched.length-this.match.length-1];let atSOL=!precedingStr/* @ Start Of File */||precedingStr==='\n';this.pushState('action');// push the parsed '%include' back into the input-to-parse // to trigger the `` state to re-parse it // and issue the desired follow-up token: 'INCLUDE': this.unput(yy_.yytext);// and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. -if(atSOL){return 22;}return 25;case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` +if(atSOL){return 22;}return 25;}case 81:/*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */this.warn(rmCommonWS` ignoring unsupported lexer option ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -2903,22 +2903,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` unterminated string constant in %options entry. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;case 100:/*! Conditions:: * */ /*! Rule:: " */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 101:/*! Conditions:: * */ /*! Rule:: ' */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 101:/*! Conditions:: * */ /*! Rule:: ' */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 102:/*! Conditions:: * */ /*! Rule:: ` */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 102:/*! Conditions:: * */ /*! Rule:: ` */{let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 39;case 103:/*! Conditions:: macro rules */ /*! Rule:: . */ /* b0rk on bad characters */var rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 39;}case 103:/*! Conditions:: macro rules */ /*! Rule:: . */{/* b0rk on bad characters */let rules=this.topState()==='macro'?'macro\'s':this.topState();yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -2930,7 +2930,7 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` regex expression here in jison-lex ${rules}. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` + `+this.prettyPrintRange(yy_.yylloc));return 2;}case 104:/*! Conditions:: options */ /*! Rule:: . */yy_.yyerror(rmCommonWS` unsupported lexer input: ${dquote(yy_.yytext)} while lexing in ${dquote(this.topState())} state. @@ -2944,22 +2944,22 @@ case 94:/*! Conditions:: action */ /*! Rule:: " */yy_.yyerror(rmCommonWS` while lexing in ${dquote(this.topState())} state. Erroneous area: - `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};var rmCommonWS=helpers.rmCommonWS;var dquote=helpers.dquote;var scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a + `+this.prettyPrintRange(yy_.yylloc));return 2;default:return this.simpleCaseActionClusters[yyrulenumber];}},simpleCaseActionClusters:{/*! Conditions:: action */ /*! Rule:: {WS}+ */16:35,/*! Conditions:: options */ /*! Rule:: = */26:18,/*! Conditions:: options */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */27:52,/*! Conditions:: options */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */28:52,/*! Conditions:: options */ /*! Rule:: `{ES2017_STRING_CONTENT}` */29:52,/*! Conditions:: options */ /*! Rule:: , */33:17,/*! Conditions:: options */ /*! Rule:: \* */34:11,/*! Conditions:: options */ /*! Rule:: {ANY_LITERAL_CHAR}+ */36:53,/*! Conditions:: rules macro INITIAL */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */45:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: '{QUOTED_STRING_CONTENT}' */46:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: `{ES2017_STRING_CONTENT}` */47:49,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \| */50:7,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?: */51:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?= */52:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?! */53:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?<= */54:40,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \(\?> */63:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: > */65:6,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:[sSbBwWdDpP]|[rfntv\\*+()${}|[\]\/.^?]) */68:42,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \$ */71:16,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \. */72:14,/*! Conditions:: rules macro INITIAL */ /*! Rule:: %pointer\b */78:'FLEX_POINTER_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: %array\b */79:'FLEX_ARRAY_MODE',/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{\d+(,\s*\d+|,)?\} */83:48,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{{ID}\} */84:44,/*! Conditions:: set options */ /*! Rule:: \{{ID}\} */85:44,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \{ */86:4,/*! Conditions:: rules macro INITIAL */ /*! Rule:: \} */87:5,/*! Conditions:: set */ /*! Rule:: (?:\\[^{BR}]|[^\]{])+ */88:47,/*! Conditions:: set */ /*! Rule:: \{ */89:47,/*! Conditions:: code */ /*! Rule:: [^{BR}]*{BR}+ */92:54,/*! Conditions:: * */ /*! Rule:: $ */106:1},rules:[/* 0: */ /^(?:\/\/[^\r\n]*)/,/* 1: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 2: */ /^(?:%\{([\s\S]*?)%\}(?!\}))/,/* 3: */ /^(?:%include\b)/,/* 4: */ /^(?:\/\*[\s\S]*?\*\/)/,/* 5: */ /^(?:\/\/.*)/,/* 6: */ /^(?:\|)/,/* 7: */ /^(?:%%)/,/* 8: */ /^(?:\/(?=\s))/,/* 9: */ /^(?:\/.*)/,/* 10: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)"|'((?:\\'|\\[^']|[^\n\r'\\])*)'|`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 11: */ /^(?:[^\n\r"%'/`{}]+)/,/* 12: */ /^(?:%)/,/* 13: */ /^(?:\{)/,/* 14: */ /^(?:\})/,/* 15: */ /^(?:(?:\s*?)(\r\n|\n|\r)+([^\S\n\r])+)/,/* 16: */ /^(?:([^\S\n\r])+)/,/* 17: */ /^(?:(\r\n|\n|\r))/,/* 18: */ /^(?:$)/,/* 19: */ /^(?:[%{]\{+)/,/* 20: */ /^(?:->)/,/* 21: */ /^(?:→)/,/* 22: */ /^(?:=>)/,/* 23: */ /^(?:([^\S\n\r])+(?!(?:\{\{|\||%|->|=>|→|([^\S\n\r])|(\r\n|\n|\r))))/,/* 24: */ /^(?:%%)/,/* 25: */ /^(?:$)/,/* 26: */ /^(?:=)/,/* 27: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 28: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 29: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 30: */ /^(?:%%|\||;)/,/* 31: */ /^(?:%include\b)/,/* 32: */ /^(?:>)/,/* 33: */ /^(?:,)/,/* 34: */ /^(?:\*)/,/* 35: */new XRegExp__default['default']('^(?:<([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)>)',''),/* 36: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 37: */ /^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,/* 38: */ /^(?:(\r\n|\n|\r))/,/* 39: */ /^(?:([^\S\n\r])+)/,/* 40: */new XRegExp__default['default']('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))',''),/* 41: */ /^(?:(\r\n|\n|\r)+)/,/* 42: */ /^(?:$)/,/* 43: */ /^(?:(\r\n|\n|\r)+)/,/* 44: */ /^(?:([^\S\n\r])+)/,/* 45: */ /^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,/* 46: */ /^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,/* 47: */ /^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,/* 48: */ /^(?:([^\s!"$%'-,./:-?\[-\^`{-}])+)/,/* 49: */ /^(?:\[)/,/* 50: */ /^(?:\|)/,/* 51: */ /^(?:\(\?:)/,/* 52: */ /^(?:\(\?=)/,/* 53: */ /^(?:\(\?!)/,/* 54: */ /^(?:\(\?<=)/,/* 55: */ /^(?:\(\?>)/,/* 64: */ /^(?:<)/,/* 65: */ /^(?:>)/,/* 66: */ /^(?:\/!)/,/* 67: */ /^(?:\/)/,/* 68: */ /^(?:\\(?:[BDPSWbdpsw]|[$(-+./?\[-\^fnrtv{-}]))/,/* 69: */ /^(?:\\(?:([0-7]{1,3})|c([A-Z])|x([\dA-Fa-f]{2})|u([\dA-Fa-f]{4})|u\{([\dA-Fa-f]{1,8})\}))/,/* 70: */ /^(?:\\.)/,/* 71: */ /^(?:\$)/,/* 72: */ /^(?:\.)/,/* 73: */ /^(?:%option[s]?)/,/* 74: */ /^(?:%s\b)/,/* 75: */ /^(?:%x\b)/,/* 76: */ /^(?:%code\b)/,/* 77: */ /^(?:%import\b)/,/* 78: */ /^(?:%pointer\b)/,/* 79: */ /^(?:%array\b)/,/* 80: */ /^(?:%include\b)/,/* 81: */new XRegExp__default['default']('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))',''),/* 82: */ /^(?:%%)/,/* 83: */ /^(?:\{\d+(,\s*\d+|,)?\})/,/* 84: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 85: */new XRegExp__default['default']('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})',''),/* 86: */ /^(?:\{)/,/* 87: */ /^(?:\})/,/* 88: */ /^(?:(?:\\[^\n\r]|[^\]{])+)/,/* 89: */ /^(?:\{)/,/* 90: */ /^(?:\])/,/* 91: */ /^(?:(?:[^\n\r%][^\n\r]*(\r\n|\n|\r)+)+)/,/* 92: */ /^(?:[^\n\r]*(\r\n|\n|\r)+)/,/* 93: */ /^(?:[^\n\r]+)/,/* 94: */ /^(?:")/,/* 95: */ /^(?:')/,/* 96: */ /^(?:`)/,/* 97: */ /^(?:")/,/* 98: */ /^(?:')/,/* 99: */ /^(?:`)/,/* 100: */ /^(?:")/,/* 101: */ /^(?:')/,/* 102: */ /^(?:`)/,/* 103: */ /^(?:.)/,/* 104: */ /^(?:.)/,/* 105: */ /^(?:.)/,/* 106: */ /^(?:$)/],conditions:{'rules':{rules:[0,1,19,20,21,22,23,24,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'macro':{rules:[0,1,20,21,22,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,82,83,84,86,87,100,101,102,103,105,106],inclusive:true},'code':{rules:[19,80,81,91,92,93,100,101,102,105,106],inclusive:false},'options':{rules:[0,1,19,26,27,28,29,30,31,32,33,34,35,36,37,38,39,85,97,98,99,100,101,102,104,105,106],inclusive:false},'action':{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,94,95,96,100,101,102,105,106],inclusive:false},'set':{rules:[85,88,89,90,100,101,102,105,106],inclusive:false},'INITIAL':{rules:[0,1,19,20,21,22,40,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,100,101,102,105,106],inclusive:true}}};const rmCommonWS=helpers.rmCommonWS;const dquote=helpers.dquote;const scanRegExp=helpers.scanRegExp;// Calculate the end marker to match and produce a // lexer rule to match when the need arrises: lexer.setupDelimitedActionChunkLexerRegex=function lexer__setupDelimitedActionChunkLexerRegex(marker){// Special: when we encounter `{` as the start of the action code block, // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! -var doNotPatch=marker==='{';var action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! +let doNotPatch=marker==='{';let action_end_marker=marker.replace(/\{/g,'}');if(!doNotPatch){// Note: this bit comes straight from the lexer kernel! // // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) -var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. +let spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps // speed up those activities a tiny bit. -spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regexes;var len=spec.__rule_count;var rules=spec.rules;var i;var action_chunk_regex;// Must we still locate the rule to patch or have we done +spec=this.__currentRuleSet__=this._currentRules();}let regexes=spec.__rule_regexes;let len=spec.__rule_count;let rules=spec.rules;let i;let action_chunk_regex;// Must we still locate the rule to patch or have we done // that already during a previous encounter? // // WARNING: our cache/patch must live beyond the current lexer+parser invocation: @@ -2972,10 +2972,10 @@ spec=this.__currentRuleSet__=this._currentRules();}var regexes=spec.__rule_regex if(!spec.__action_chunk_rule_idx){// **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! -var orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';var orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. +let orig_re_str1='/^(?:%\\{([^]*?)%\\}(?!\\}))/';let orig_re_str2='/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/';// the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! -for(i=1;i<=len;i++){var rule_re=regexes[i];var re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); +for(i=1;i<=len;i++){let rule_re=regexes[i];let re_str=rule_re.toString();//console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if(re_str===orig_re_str1||re_str===orig_re_str2){spec.__action_chunk_rule_idx=i;break;}}if(!spec.__action_chunk_rule_idx){//console.error('ruleset dump:', spec); throw new Error('INTERNAL DEV ERROR: cannot locate %{...%} rule regex!');}// As we haven't initialized yet, we're sure the rule cache doesn't exist either. // Make it happen: @@ -2985,7 +2985,7 @@ spec.__cached_action_chunk_rule={};// set up empty cache action_chunk_regex=spec.__cached_action_chunk_rule[marker];if(!action_chunk_regex){action_chunk_regex=spec.__cached_action_chunk_rule[marker]=new RegExp('^(?:'+marker.replace(/\{/g,'\\{')+'([^]*?)'+action_end_marker.replace(/\}/g,'\\}')+'(?!\\}))');//console.warn('encode new action block regex:', action_chunk_regex); }//console.error('new ACTION REGEX:', { i, action_chunk_regex }); // and patch the lexer regex table for the current lexer condition state: -regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser.lexer=lexer;var rmCommonWS$1=helpers.rmCommonWS;var checkActionBlock$1=helpers.checkActionBlock;var mkIdentifier$1=helpers.mkIdentifier;var isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;var trimActionCode$1=helpers.trimActionCode;// see also: +regexes[i]=action_chunk_regex;}return action_end_marker;};lexer.warn=function l_warn(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.warn==='function'){return this.yy.parser.warn.apply(this,arguments);}else{console.warn.apply(console,arguments);}};lexer.log=function l_log(){if(this.yy&&this.yy.parser&&typeof this.yy.parser.log==='function'){return this.yy.parser.log.apply(this,arguments);}else{console.log.apply(console,arguments);}};return lexer;}();parser.lexer=lexer;const rmCommonWS$1=helpers.rmCommonWS;const checkActionBlock$1=helpers.checkActionBlock;const mkIdentifier$1=helpers.mkIdentifier;const isLegalIdentifierInput$1=helpers.isLegalIdentifierInput;const trimActionCode$1=helpers.trimActionCode;// see also: // - https://en.wikipedia.org/wiki/C0_and_C1_control_codes // - https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-escapes-in-regular-expressions // - https://kangax.github.io/compat-table/es6/#test-RegExp_y_and_u_flags @@ -2997,27 +2997,27 @@ const charCvtTable={// "\a": "\x07", "\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v"};const escCvtTable={"a":"\\x07","e":"\\x1B","b":"\\x08","f":"\\f","n":"\\n","r":"\\r","t":"\\t","v":"\\v"};const codeCvtTable={12:"\\f",10:"\\n",13:"\\r",9:"\\t",11:"\\v"};// Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){var rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){var rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); -for(var i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead +const codedCharRe=/(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g;function encodeCharCode(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCharCode(v);}}function encodeUnicodeCodepoint(v){if(v<32){let rv=codeCvtTable[v];if(rv)return rv;return'\\u'+('0000'+v.toString(16)).substr(-4);}else{return String.fromCodePoint(v);}}function encodeRegexLiteralStr(s,edge){let rv='';//console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); +for(let i=0,l=s.length;i=0){rv+='\\\\'+c;continue;}if(c==='\\'){rv+='\\\\';continue;}codedCharRe.lastIndex=i;// we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. -var m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s +let m=codedCharRe.exec(s);if(m&&m[0]){if(m[1]){// [1]: regex operators, which occur in a literal string: `\s` --> \\s rv+='\\\\'+m[1];i+=m[1].length-1;continue;}if(m[2]){// [2]: regex special characters, which occur in a literal string: `\[` --> \\\[ rv+='\\\\\\'+m[2];i+=m[2].length-1;continue;}if(m[3]){// [3]: special escape characters, which occur in a literal string: `\a` --> BELL rv+=escCvtTable[m[3]];i+=m[3].length-1;continue;}if(m[4]){// [4]: octal char: `\012` --> \x0A -var v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 -var v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A -var v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI -var v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI -var v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: +let v=parseInt(m[4],8);rv+=encodeCharCode(v);i+=m[4].length-1;continue;}if(m[5]){// [5]: CONTROL char: `\cA` --> \u0001 +let v=m[5].charCodeAt(0)-64;rv+=encodeCharCode(v);i++;continue;}if(m[6]){// [6]: hex char: `\x41` --> A +let v=parseInt(m[6],16);rv+=encodeCharCode(v);i+=m[6].length;continue;}if(m[7]){// [7]: unicode/UTS2 char: `\u03c0` --> PI +let v=parseInt(m[7],16);rv+=encodeCharCode(v);i+=m[7].length;continue;}if(m[8]){// [8]: unicode code point: `\u{00003c0}` --> PI +let v=parseInt(m[8],16);rv+=encodeUnicodeCodepoint(v);i+=m[8].length;continue;}}}// all the rest: simply treat the `\\` escape as a character on its own: rv+='\\\\';i--;continue;default:// escape regex operators: -var pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}var cc=charCvtTable[c];if(cc){rv+=cc;continue;}var cc=c.charCodeAt(0);if(cc<32){var rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); +let pos=".*+?^${}()|[]/\\".indexOf(c);if(pos>=0){rv+='\\'+c;continue;}let cc=charCvtTable[c];if(cc){rv+=cc;continue;}cc=c.charCodeAt(0);if(cc<32){let rvp=codeCvtTable[v];if(rvp){rv+=rvp;}else{rv+='\\u'+('0000'+cc.toString(16)).substr(-4);}}else{rv+=c;}continue;}}s=rv;//console.warn("encodeRegexLiteralStr ROUND 3:", {s}); return s;}// convert string value to number or boolean value, when possible // (and when this is more or less obviously the intent) // otherwise produce the string itself as value. function parseValue(v){if(v==='false'){return false;}if(v==='true'){return true;}// http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) -if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser.warn=function p_warn(){console.warn.apply(console,arguments);};parser.log=function p_log(){console.log.apply(console,arguments);};parser.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse:',arguments);};parser.yy.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse YY:',arguments);};parser.yy.post_lex=function p_lex(){if(parser.yydebug)parser.log('post_lex:',arguments);};function Parser(){this.yy={};}Parser.prototype=parser;parser.Parser=Parser;function yyparse(){return parser.parse.apply(parser,arguments);}var lexParser={parser,Parser,parse:yyparse};// +if(v&&!isNaN(v)){let rv=+v;if(isFinite(rv)){return rv;}}return v;}parser.warn=function p_warn(){console.warn.apply(console,arguments);};parser.log=function p_log(){console.log.apply(console,arguments);};parser.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse:',arguments);};parser.yy.pre_parse=function p_lex(){if(parser.yydebug)parser.log('pre_parse YY:',arguments);};parser.yy.post_lex=function p_lex(){if(parser.yydebug)parser.log('post_lex:',arguments);};function Parser(){this.yy={};}Parser.prototype=parser;parser.Parser=Parser;function yyparse(){return parser.parse.apply(parser,arguments);}var lexParser={parser,Parser,parse:yyparse};// const XREGEXP_UNICODE_ESCAPE_RE=/^\{[A-Za-z0-9 \-\._]+\}/;// Matches the XRegExp Unicode escape braced part, e.g. `{Number}` const CHR_RE=/^(?:[^\\]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})/;const SET_PART_RE=/^(?:[^\\\]]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;const NOTHING_SPECIAL_RE=/^(?:[^\\\[\]\(\)\|^\{\}]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;const SET_IS_SINGLE_PCODE_RE=/^\\[dDwWsS]$|^\\p\{[A-Za-z0-9 \-\._]+\}$/;const UNICODE_BASE_PLANE_MAX_CP=65535;// The expanded regex sets which are equivalent to the given `\\{c}` escapes: // @@ -3320,7 +3320,10 @@ action=helpers.printFunctionSourceCodeContainer(action).code;}action=action.repl // which would then cause havoc when our action code analysis (using regexes or otherwise) was 'too simple' // to catch these culprits; hence we resort and stick with the most fundamental approach here: // always append `break;` even when it would be obvious to a human that such would be 'unreachable code'. -let match_nr=/^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim());if(match_nr){simple_rule_count++;caseHelper.push([].concat(code,i,':',match_nr[1]).join(' ').replace(/[\n]/g,'\n '));}else{regular_rule_count++;routingCode.push([].concat('case',i,':',code,action,'\nbreak;').join(' '));}}if(simple_rule_count){routingCode.push('default:');routingCode.push(' return this.simpleCaseActionClusters[yyrulenumber];');}routingCode.push('}');// only inject the big switch/case chunk when there's any `switch` or `default` branch to switch to: +let match_nr=/^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim());if(match_nr){simple_rule_count++;caseHelper.push([].concat(code,i,':',match_nr[1]).join(' ').replace(/[\n]/g,'\n '));}else{regular_rule_count++;// If action includes the keyword `let` or `const`, then it's ES6 code +// which must be scoped to prevent collisions with other action code chunks +// in the same large generated switch/case statement: +if(/\blet\b/.test(action)||/\bconst\b/.test(action)){action='{\n'+action+'\n}';}routingCode.push([].concat('case',i,':',code,action,'\nbreak;').join(' '));}}if(simple_rule_count){routingCode.push('default:');routingCode.push(' return this.simpleCaseActionClusters[yyrulenumber];');}routingCode.push('}');// only inject the big switch/case chunk when there's any `switch` or `default` branch to switch to: if(simple_rule_count+regular_rule_count>0){actions.push.apply(actions,routingCode);}else{actions.push('/* no rules ==> no rule SWITCH! */');}return{rules:newRules,// array listing only the lexer spec regexes macros:macros,regular_rule_count:regular_rule_count,simple_rule_count:simple_rule_count};}// expand all macros (with maybe one exception) in the given regex: the macros may exist inside `[...]` regex sets or // elsewhere, which requires two different treatments to expand these macros. diff --git a/packages/jison-lex/dist/regexp-lexer-umd.js b/packages/jison-lex/dist/regexp-lexer-umd.js index 9eddea287..1b5621179 100644 --- a/packages/jison-lex/dist/regexp-lexer-umd.js +++ b/packages/jison-lex/dist/regexp-lexer-umd.js @@ -2555,20 +2555,21 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2578,6 +2579,7 @@ delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2727,6 +2729,7 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2735,9 +2738,9 @@ break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -2784,6 +2787,7 @@ break; } } + } break; case 9: @@ -2868,8 +2872,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -2877,6 +2882,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -2907,8 +2913,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -2916,6 +2923,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -2946,9 +2954,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -2960,6 +2969,7 @@ yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -2985,8 +2995,6 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3007,8 +3015,9 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3023,6 +3032,7 @@ ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3033,11 +3043,13 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3082,10 +3094,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3114,6 +3127,7 @@ type: 'imports', body: body }; + } break; case 24: @@ -3147,10 +3161,11 @@ // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3172,8 +3187,8 @@ `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3189,6 +3204,7 @@ include: srcCode } }; + } break; case 26: @@ -3200,9 +3216,10 @@ // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3216,6 +3233,7 @@ Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3428,9 +3446,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3442,6 +3461,7 @@ yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3465,8 +3485,8 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3477,6 +3497,7 @@ ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3487,13 +3508,14 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3523,6 +3545,7 @@ `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3688,8 +3711,9 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3699,6 +3723,7 @@ `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3709,7 +3734,8 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3727,7 +3753,7 @@ srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3742,6 +3768,7 @@ } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3987,9 +4014,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4017,6 +4045,7 @@ // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4028,8 +4057,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4044,6 +4074,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4054,6 +4085,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4108,13 +4140,14 @@ } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4402,10 +4435,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4416,8 +4451,10 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4428,6 +4465,7 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4438,7 +4476,7 @@ `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4455,6 +4493,7 @@ } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4550,7 +4589,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4563,6 +4603,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4573,6 +4614,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -4581,7 +4623,7 @@ // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4598,6 +4640,7 @@ } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4608,11 +4651,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4626,6 +4670,7 @@ ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4669,9 +4714,10 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4682,6 +4728,7 @@ } } this.$ = srcCode; + } break; case 126: @@ -4733,9 +4780,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4749,6 +4797,7 @@ // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4759,8 +4808,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4771,6 +4820,7 @@ ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -4794,10 +4844,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -4826,11 +4877,11 @@ } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -4842,6 +4893,7 @@ } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -9991,21 +10043,22 @@ case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10099,55 +10152,55 @@ case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } - - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } + + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10155,24 +10208,25 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10200,44 +10254,45 @@ case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10362,38 +10417,39 @@ case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10433,29 +10489,30 @@ case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10559,49 +10616,56 @@ case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10615,7 +10679,8 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11192,9 +11257,9 @@ } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11203,9 +11268,9 @@ // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11213,7 +11278,7 @@ // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11223,11 +11288,11 @@ spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11243,15 +11308,15 @@ // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11311,11 +11376,11 @@ }(); parser.lexer = lexer; - var rmCommonWS$1 = helpers.rmCommonWS; - var checkActionBlock$1 = helpers.checkActionBlock; - var mkIdentifier$1 = helpers.mkIdentifier; - var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; - var trimActionCode$1 = helpers.trimActionCode; + const rmCommonWS$1 = helpers.rmCommonWS; + const checkActionBlock$1 = helpers.checkActionBlock; + const mkIdentifier$1 = helpers.mkIdentifier; + const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; + const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11356,11 +11421,11 @@ // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. - var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; + const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11370,7 +11435,7 @@ function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11379,10 +11444,10 @@ } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11392,7 +11457,7 @@ rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11405,7 +11470,7 @@ // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11427,35 +11492,35 @@ } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11469,19 +11534,19 @@ default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11512,7 +11577,7 @@ // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } @@ -12898,6 +12963,12 @@ caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } diff --git a/packages/jison-lex/examples/output/c99.l-ref.json5 b/packages/jison-lex/examples/output/c99.l-ref.json5 index 3079b51d5..8710583f1 100644 --- a/packages/jison-lex/examples/output/c99.l-ref.json5 +++ b/packages/jison-lex/examples/output/c99.l-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'sym_type is not defined', stack: `ReferenceError: sym_type is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/output/ccalc-lex.l-ref.json5 b/packages/jison-lex/examples/output/ccalc-lex.l-ref.json5 index 4118f1eae..2d6e1bc6a 100644 --- a/packages/jison-lex/examples/output/ccalc-lex.l-ref.json5 +++ b/packages/jison-lex/examples/output/ccalc-lex.l-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'BeginToken is not defined', stack: `ReferenceError: BeginToken is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/output/comments.jison-ref.json5 b/packages/jison-lex/examples/output/comments.jison-ref.json5 index 2deeffd4f..fedb28aca 100644 --- a/packages/jison-lex/examples/output/comments.jison-ref.json5 +++ b/packages/jison-lex/examples/output/comments.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'getTypes is not defined', stack: `ReferenceError: getTypes is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/output/faking-multiple-start-rules-alt.jison-lexer.js b/packages/jison-lex/examples/output/faking-multiple-start-rules-alt.jison-lexer.js index ae3ff5c85..db3243eb3 100644 --- a/packages/jison-lex/examples/output/faking-multiple-start-rules-alt.jison-lexer.js +++ b/packages/jison-lex/examples/output/faking-multiple-start-rules-alt.jison-lexer.js @@ -1420,7 +1420,8 @@ break; case 3 : /*! Conditions:: PARSE_MODE_DETECTION */ /*! Rule:: . */ - this.popState(); + { +this.popState(); console.log('detected DEFAULT (value) mode'); /* * When we did not observe one of the special character codes at the forefront of our @@ -1538,14 +1539,17 @@ case 3 : // Pick the default parse mode: this.pushState('VALUE_MODE'); - return 'VALUE_PARSE_MODE' + return 'VALUE_PARSE_MODE' +} break; case 4 : /*! Conditions:: PARSE_MODE_DETECTION */ /*! Rule:: $ */ - this.popState(); + { +this.popState(); // let the previous lexer state process that EOF for real... - return false + return false +} break; case 6 : /*! Conditions:: VALUE_MODE */ @@ -2259,7 +2263,8 @@ break; case 3 : /*! Conditions:: PARSE_MODE_DETECTION */ /*! Rule:: . */ - this.popState(); + { +this.popState(); console.log('detected DEFAULT (value) mode'); /* * When we did not observe one of the special character codes at the forefront of our @@ -2377,14 +2382,17 @@ case 3 : // Pick the default parse mode: this.pushState('VALUE_MODE'); - return 'VALUE_PARSE_MODE' + return 'VALUE_PARSE_MODE' +} break; case 4 : /*! Conditions:: PARSE_MODE_DETECTION */ /*! Rule:: $ */ - this.popState(); + { +this.popState(); // let the previous lexer state process that EOF for real... - return false + return false +} break; case 6 : /*! Conditions:: VALUE_MODE */ diff --git a/packages/jison-lex/examples/output/issue-19-jison_lex-fixed.jison-ref.json5 b/packages/jison-lex/examples/output/issue-19-jison_lex-fixed.jison-ref.json5 index c7808b632..fd9fb9ab1 100644 --- a/packages/jison-lex/examples/output/issue-19-jison_lex-fixed.jison-ref.json5 +++ b/packages/jison-lex/examples/output/issue-19-jison_lex-fixed.jison-ref.json5 @@ -90,9 +90,9 @@ Erroneous area: 1: ;;a;aBaa ^.......^ - at Object.lexer_parseError [as parseError] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer_parseError [as parseError] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/output/lex.l-ref.json5 b/packages/jison-lex/examples/output/lex.l-ref.json5 index 723d4913a..38660bfbc 100644 --- a/packages/jison-lex/examples/output/lex.l-ref.json5 +++ b/packages/jison-lex/examples/output/lex.l-ref.json5 @@ -37,10 +37,10 @@ name: 'ReferenceError', message: 'rmCommonWS is not defined', stack: `ReferenceError: rmCommonWS is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/output/pascal.l-ref.json5 b/packages/jison-lex/examples/output/pascal.l-ref.json5 index ed2d1c650..d129d4f3b 100644 --- a/packages/jison-lex/examples/output/pascal.l-ref.json5 +++ b/packages/jison-lex/examples/output/pascal.l-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'PROGRAM is not defined', stack: `ReferenceError: PROGRAM is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/output/unicode.jison-lexer.js b/packages/jison-lex/examples/output/unicode.jison-lexer.js index c955658d8..f4f35f07f 100644 --- a/packages/jison-lex/examples/output/unicode.jison-lexer.js +++ b/packages/jison-lex/examples/output/unicode.jison-lexer.js @@ -2122,7 +2122,8 @@ break; case 11 : /*! Conditions:: INLINE_COMMENT */ /*! Rule:: . */ - for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { + { +for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { s2 = this.inline_comment_end_markers[rv]; if (s2[0] === this.matches[0]) { // we got a POTENTIAL MATCH; let's see if we need more: @@ -2153,7 +2154,8 @@ case 11 : } } // collect input until we hit something we know: - this.more() + this.more() +} break; case 12 : /*! Conditions:: INLINE_COMMENT */ @@ -4130,7 +4132,8 @@ break; case 11 : /*! Conditions:: INLINE_COMMENT */ /*! Rule:: . */ - for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { + { +for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { s2 = this.inline_comment_end_markers[rv]; if (s2[0] === this.matches[0]) { // we got a POTENTIAL MATCH; let's see if we need more: @@ -4161,7 +4164,8 @@ case 11 : } } // collect input until we hit something we know: - this.more() + this.more() +} break; case 12 : /*! Conditions:: INLINE_COMMENT */ diff --git a/packages/jison-lex/examples/output/unicode.jison-ref.json5 b/packages/jison-lex/examples/output/unicode.jison-ref.json5 index 538ce9e95..ab5acc6fa 100644 --- a/packages/jison-lex/examples/output/unicode.jison-ref.json5 +++ b/packages/jison-lex/examples/output/unicode.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'is_constant is not defined', stack: `ReferenceError: is_constant is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/output/unicode2.jison-lexer.js b/packages/jison-lex/examples/output/unicode2.jison-lexer.js index c955658d8..f4f35f07f 100644 --- a/packages/jison-lex/examples/output/unicode2.jison-lexer.js +++ b/packages/jison-lex/examples/output/unicode2.jison-lexer.js @@ -2122,7 +2122,8 @@ break; case 11 : /*! Conditions:: INLINE_COMMENT */ /*! Rule:: . */ - for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { + { +for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { s2 = this.inline_comment_end_markers[rv]; if (s2[0] === this.matches[0]) { // we got a POTENTIAL MATCH; let's see if we need more: @@ -2153,7 +2154,8 @@ case 11 : } } // collect input until we hit something we know: - this.more() + this.more() +} break; case 12 : /*! Conditions:: INLINE_COMMENT */ @@ -4130,7 +4132,8 @@ break; case 11 : /*! Conditions:: INLINE_COMMENT */ /*! Rule:: . */ - for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { + { +for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { s2 = this.inline_comment_end_markers[rv]; if (s2[0] === this.matches[0]) { // we got a POTENTIAL MATCH; let's see if we need more: @@ -4161,7 +4164,8 @@ case 11 : } } // collect input until we hit something we know: - this.more() + this.more() +} break; case 12 : /*! Conditions:: INLINE_COMMENT */ diff --git a/packages/jison-lex/examples/output/unicode2.jison-ref.json5 b/packages/jison-lex/examples/output/unicode2.jison-ref.json5 index 538ce9e95..ab5acc6fa 100644 --- a/packages/jison-lex/examples/output/unicode2.jison-ref.json5 +++ b/packages/jison-lex/examples/output/unicode2.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'is_constant is not defined', stack: `ReferenceError: is_constant is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/reference-output/c99.l-ref.json5 b/packages/jison-lex/examples/reference-output/c99.l-ref.json5 index 3079b51d5..8710583f1 100644 --- a/packages/jison-lex/examples/reference-output/c99.l-ref.json5 +++ b/packages/jison-lex/examples/reference-output/c99.l-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'sym_type is not defined', stack: `ReferenceError: sym_type is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/reference-output/ccalc-lex.l-ref.json5 b/packages/jison-lex/examples/reference-output/ccalc-lex.l-ref.json5 index 4118f1eae..2d6e1bc6a 100644 --- a/packages/jison-lex/examples/reference-output/ccalc-lex.l-ref.json5 +++ b/packages/jison-lex/examples/reference-output/ccalc-lex.l-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'BeginToken is not defined', stack: `ReferenceError: BeginToken is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/reference-output/comments.jison-ref.json5 b/packages/jison-lex/examples/reference-output/comments.jison-ref.json5 index 2deeffd4f..fedb28aca 100644 --- a/packages/jison-lex/examples/reference-output/comments.jison-ref.json5 +++ b/packages/jison-lex/examples/reference-output/comments.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'getTypes is not defined', stack: `ReferenceError: getTypes is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/reference-output/faking-multiple-start-rules-alt.jison-lexer.js b/packages/jison-lex/examples/reference-output/faking-multiple-start-rules-alt.jison-lexer.js index ae3ff5c85..db3243eb3 100644 --- a/packages/jison-lex/examples/reference-output/faking-multiple-start-rules-alt.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/faking-multiple-start-rules-alt.jison-lexer.js @@ -1420,7 +1420,8 @@ break; case 3 : /*! Conditions:: PARSE_MODE_DETECTION */ /*! Rule:: . */ - this.popState(); + { +this.popState(); console.log('detected DEFAULT (value) mode'); /* * When we did not observe one of the special character codes at the forefront of our @@ -1538,14 +1539,17 @@ case 3 : // Pick the default parse mode: this.pushState('VALUE_MODE'); - return 'VALUE_PARSE_MODE' + return 'VALUE_PARSE_MODE' +} break; case 4 : /*! Conditions:: PARSE_MODE_DETECTION */ /*! Rule:: $ */ - this.popState(); + { +this.popState(); // let the previous lexer state process that EOF for real... - return false + return false +} break; case 6 : /*! Conditions:: VALUE_MODE */ @@ -2259,7 +2263,8 @@ break; case 3 : /*! Conditions:: PARSE_MODE_DETECTION */ /*! Rule:: . */ - this.popState(); + { +this.popState(); console.log('detected DEFAULT (value) mode'); /* * When we did not observe one of the special character codes at the forefront of our @@ -2377,14 +2382,17 @@ case 3 : // Pick the default parse mode: this.pushState('VALUE_MODE'); - return 'VALUE_PARSE_MODE' + return 'VALUE_PARSE_MODE' +} break; case 4 : /*! Conditions:: PARSE_MODE_DETECTION */ /*! Rule:: $ */ - this.popState(); + { +this.popState(); // let the previous lexer state process that EOF for real... - return false + return false +} break; case 6 : /*! Conditions:: VALUE_MODE */ diff --git a/packages/jison-lex/examples/reference-output/issue-19-jison_lex-fixed.jison-ref.json5 b/packages/jison-lex/examples/reference-output/issue-19-jison_lex-fixed.jison-ref.json5 index c7808b632..fd9fb9ab1 100644 --- a/packages/jison-lex/examples/reference-output/issue-19-jison_lex-fixed.jison-ref.json5 +++ b/packages/jison-lex/examples/reference-output/issue-19-jison_lex-fixed.jison-ref.json5 @@ -90,9 +90,9 @@ Erroneous area: 1: ;;a;aBaa ^.......^ - at Object.lexer_parseError [as parseError] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer_parseError [as parseError] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/reference-output/lex.l-ref.json5 b/packages/jison-lex/examples/reference-output/lex.l-ref.json5 index 723d4913a..38660bfbc 100644 --- a/packages/jison-lex/examples/reference-output/lex.l-ref.json5 +++ b/packages/jison-lex/examples/reference-output/lex.l-ref.json5 @@ -37,10 +37,10 @@ name: 'ReferenceError', message: 'rmCommonWS is not defined', stack: `ReferenceError: rmCommonWS is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/reference-output/pascal.l-ref.json5 b/packages/jison-lex/examples/reference-output/pascal.l-ref.json5 index ed2d1c650..d129d4f3b 100644 --- a/packages/jison-lex/examples/reference-output/pascal.l-ref.json5 +++ b/packages/jison-lex/examples/reference-output/pascal.l-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'PROGRAM is not defined', stack: `ReferenceError: PROGRAM is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/reference-output/unicode.jison-lexer.js b/packages/jison-lex/examples/reference-output/unicode.jison-lexer.js index c955658d8..f4f35f07f 100644 --- a/packages/jison-lex/examples/reference-output/unicode.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/unicode.jison-lexer.js @@ -2122,7 +2122,8 @@ break; case 11 : /*! Conditions:: INLINE_COMMENT */ /*! Rule:: . */ - for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { + { +for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { s2 = this.inline_comment_end_markers[rv]; if (s2[0] === this.matches[0]) { // we got a POTENTIAL MATCH; let's see if we need more: @@ -2153,7 +2154,8 @@ case 11 : } } // collect input until we hit something we know: - this.more() + this.more() +} break; case 12 : /*! Conditions:: INLINE_COMMENT */ @@ -4130,7 +4132,8 @@ break; case 11 : /*! Conditions:: INLINE_COMMENT */ /*! Rule:: . */ - for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { + { +for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { s2 = this.inline_comment_end_markers[rv]; if (s2[0] === this.matches[0]) { // we got a POTENTIAL MATCH; let's see if we need more: @@ -4161,7 +4164,8 @@ case 11 : } } // collect input until we hit something we know: - this.more() + this.more() +} break; case 12 : /*! Conditions:: INLINE_COMMENT */ diff --git a/packages/jison-lex/examples/reference-output/unicode.jison-ref.json5 b/packages/jison-lex/examples/reference-output/unicode.jison-ref.json5 index 538ce9e95..ab5acc6fa 100644 --- a/packages/jison-lex/examples/reference-output/unicode.jison-ref.json5 +++ b/packages/jison-lex/examples/reference-output/unicode.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'is_constant is not defined', stack: `ReferenceError: is_constant is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/examples/reference-output/unicode2.jison-lexer.js b/packages/jison-lex/examples/reference-output/unicode2.jison-lexer.js index c955658d8..f4f35f07f 100644 --- a/packages/jison-lex/examples/reference-output/unicode2.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/unicode2.jison-lexer.js @@ -2122,7 +2122,8 @@ break; case 11 : /*! Conditions:: INLINE_COMMENT */ /*! Rule:: . */ - for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { + { +for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { s2 = this.inline_comment_end_markers[rv]; if (s2[0] === this.matches[0]) { // we got a POTENTIAL MATCH; let's see if we need more: @@ -2153,7 +2154,8 @@ case 11 : } } // collect input until we hit something we know: - this.more() + this.more() +} break; case 12 : /*! Conditions:: INLINE_COMMENT */ @@ -4130,7 +4132,8 @@ break; case 11 : /*! Conditions:: INLINE_COMMENT */ /*! Rule:: . */ - for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { + { +for (rv = 0, len = this.inline_comment_end_markers.length; rv < len; rv++) { s2 = this.inline_comment_end_markers[rv]; if (s2[0] === this.matches[0]) { // we got a POTENTIAL MATCH; let's see if we need more: @@ -4161,7 +4164,8 @@ case 11 : } } // collect input until we hit something we know: - this.more() + this.more() +} break; case 12 : /*! Conditions:: INLINE_COMMENT */ diff --git a/packages/jison-lex/examples/reference-output/unicode2.jison-ref.json5 b/packages/jison-lex/examples/reference-output/unicode2.jison-ref.json5 index 538ce9e95..ab5acc6fa 100644 --- a/packages/jison-lex/examples/reference-output/unicode2.jison-ref.json5 +++ b/packages/jison-lex/examples/reference-output/unicode2.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'is_constant is not defined', stack: `ReferenceError: is_constant is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/regexp-lexer.js b/packages/jison-lex/regexp-lexer.js index 72dbb0ba5..92b68658f 100644 --- a/packages/jison-lex/regexp-lexer.js +++ b/packages/jison-lex/regexp-lexer.js @@ -383,6 +383,12 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n ')); } else { regular_rule_count++; + // If action includes the keyword `let` or `const`, then it's ES6 code + // which must be scoped to prevent collisions with other action code chunks + // in the same large generated switch/case statement: + if (/\blet\b/.test(action) || /\bconst\b/.test(action)) { + action = '{\n' + action + '\n}'; + } routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' ')); } } diff --git a/packages/jison-lex/tests/specs/output/004-unspecified-condition-state.jison-lexer.js b/packages/jison-lex/tests/specs/output/004-unspecified-condition-state.jison-lexer.js index 7afed1941..2a1ef1a99 100644 --- a/packages/jison-lex/tests/specs/output/004-unspecified-condition-state.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/004-unspecified-condition-state.jison-lexer.js @@ -28,10 +28,10 @@ while JSON5 Mode produces Error: JSON5: invalid character '%' at 2:1`, at Object.value (/index.js:964:16) at lex (/index.js:743:41) at Object.parse (/index.js:689:18) - at autodetectAndConvertToJSONformat (/regexp-lexer-cjs.js:12706:51) - at processGrammar (/regexp-lexer-cjs.js:15431:12) - at test_me (/regexp-lexer-cjs.js:13619:16) - at new RegExpLexer (/regexp-lexer-cjs.js:13737:17) + at autodetectAndConvertToJSONformat (/regexp-lexer-cjs.js:12771:51) + at processGrammar (/regexp-lexer-cjs.js:15502:12) + at test_me (/regexp-lexer-cjs.js:13690:16) + at new RegExpLexer (/regexp-lexer-cjs.js:13808:17) at Context.testEachLexerExample (/regexplexer.js:3637:25) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/output/004-unspecified-condition-state.jison-ref.json5 b/packages/jison-lex/tests/specs/output/004-unspecified-condition-state.jison-ref.json5 index 71b08f6b2..b3d933db8 100644 --- a/packages/jison-lex/tests/specs/output/004-unspecified-condition-state.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/output/004-unspecified-condition-state.jison-ref.json5 @@ -32,10 +32,10 @@ while JSON5 Mode produces Error: JSON5: invalid character '%' at 2:1`, at Object.value (/index.js:964:16) at lex (/index.js:743:41) at Object.parse (/index.js:689:18) - at autodetectAndConvertToJSONformat (/regexp-lexer-cjs.js:12706:51) - at processGrammar (/regexp-lexer-cjs.js:15431:12) - at test_me (/regexp-lexer-cjs.js:13619:16) - at new RegExpLexer (/regexp-lexer-cjs.js:13737:17) + at autodetectAndConvertToJSONformat (/regexp-lexer-cjs.js:12771:51) + at processGrammar (/regexp-lexer-cjs.js:15502:12) + at test_me (/regexp-lexer-cjs.js:13690:16) + at new RegExpLexer (/regexp-lexer-cjs.js:13808:17) at Context.testEachLexerExample (/regexplexer.js:3637:25) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/output/006-multiple-action-chunks.jison-ref.json5 b/packages/jison-lex/tests/specs/output/006-multiple-action-chunks.jison-ref.json5 index e98ef86c7..111abdf4b 100644 --- a/packages/jison-lex/tests/specs/output/006-multiple-action-chunks.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/output/006-multiple-action-chunks.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'block0A is not defined', stack: `ReferenceError: block0A is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/output/007-multiple-action-chunks-with-includes.jison-ref.json5 b/packages/jison-lex/tests/specs/output/007-multiple-action-chunks-with-includes.jison-ref.json5 index e98ef86c7..111abdf4b 100644 --- a/packages/jison-lex/tests/specs/output/007-multiple-action-chunks-with-includes.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/output/007-multiple-action-chunks-with-includes.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'block0A is not defined', stack: `ReferenceError: block0A is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/output/008-template-string-in-action.jison-ref.json5 b/packages/jison-lex/tests/specs/output/008-template-string-in-action.jison-ref.json5 index e54fa4c0b..1b82862bf 100644 --- a/packages/jison-lex/tests/specs/output/008-template-string-in-action.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/output/008-template-string-in-action.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/output/009-template-string-in-action.jison-ref.json5 b/packages/jison-lex/tests/specs/output/009-template-string-in-action.jison-ref.json5 index e54fa4c0b..1b82862bf 100644 --- a/packages/jison-lex/tests/specs/output/009-template-string-in-action.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/output/009-template-string-in-action.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/output/010-action-code-marker-alternatives.jison-ref.json5 b/packages/jison-lex/tests/specs/output/010-action-code-marker-alternatives.jison-ref.json5 index e54fa4c0b..1b82862bf 100644 --- a/packages/jison-lex/tests/specs/output/010-action-code-marker-alternatives.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/output/010-action-code-marker-alternatives.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/output/011-action-code-marker-alternatives.jison-ref.json5 b/packages/jison-lex/tests/specs/output/011-action-code-marker-alternatives.jison-ref.json5 index e54fa4c0b..1b82862bf 100644 --- a/packages/jison-lex/tests/specs/output/011-action-code-marker-alternatives.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/output/011-action-code-marker-alternatives.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/reference-output/004-unspecified-condition-state.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/004-unspecified-condition-state.jison-lexer.js index 7afed1941..2a1ef1a99 100644 --- a/packages/jison-lex/tests/specs/reference-output/004-unspecified-condition-state.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/004-unspecified-condition-state.jison-lexer.js @@ -28,10 +28,10 @@ while JSON5 Mode produces Error: JSON5: invalid character '%' at 2:1`, at Object.value (/index.js:964:16) at lex (/index.js:743:41) at Object.parse (/index.js:689:18) - at autodetectAndConvertToJSONformat (/regexp-lexer-cjs.js:12706:51) - at processGrammar (/regexp-lexer-cjs.js:15431:12) - at test_me (/regexp-lexer-cjs.js:13619:16) - at new RegExpLexer (/regexp-lexer-cjs.js:13737:17) + at autodetectAndConvertToJSONformat (/regexp-lexer-cjs.js:12771:51) + at processGrammar (/regexp-lexer-cjs.js:15502:12) + at test_me (/regexp-lexer-cjs.js:13690:16) + at new RegExpLexer (/regexp-lexer-cjs.js:13808:17) at Context.testEachLexerExample (/regexplexer.js:3637:25) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/reference-output/004-unspecified-condition-state.jison-ref.json5 b/packages/jison-lex/tests/specs/reference-output/004-unspecified-condition-state.jison-ref.json5 index 71b08f6b2..b3d933db8 100644 --- a/packages/jison-lex/tests/specs/reference-output/004-unspecified-condition-state.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/reference-output/004-unspecified-condition-state.jison-ref.json5 @@ -32,10 +32,10 @@ while JSON5 Mode produces Error: JSON5: invalid character '%' at 2:1`, at Object.value (/index.js:964:16) at lex (/index.js:743:41) at Object.parse (/index.js:689:18) - at autodetectAndConvertToJSONformat (/regexp-lexer-cjs.js:12706:51) - at processGrammar (/regexp-lexer-cjs.js:15431:12) - at test_me (/regexp-lexer-cjs.js:13619:16) - at new RegExpLexer (/regexp-lexer-cjs.js:13737:17) + at autodetectAndConvertToJSONformat (/regexp-lexer-cjs.js:12771:51) + at processGrammar (/regexp-lexer-cjs.js:15502:12) + at test_me (/regexp-lexer-cjs.js:13690:16) + at new RegExpLexer (/regexp-lexer-cjs.js:13808:17) at Context.testEachLexerExample (/regexplexer.js:3637:25) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/reference-output/006-multiple-action-chunks.jison-ref.json5 b/packages/jison-lex/tests/specs/reference-output/006-multiple-action-chunks.jison-ref.json5 index e98ef86c7..111abdf4b 100644 --- a/packages/jison-lex/tests/specs/reference-output/006-multiple-action-chunks.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/reference-output/006-multiple-action-chunks.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'block0A is not defined', stack: `ReferenceError: block0A is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/reference-output/007-multiple-action-chunks-with-includes.jison-ref.json5 b/packages/jison-lex/tests/specs/reference-output/007-multiple-action-chunks-with-includes.jison-ref.json5 index e98ef86c7..111abdf4b 100644 --- a/packages/jison-lex/tests/specs/reference-output/007-multiple-action-chunks-with-includes.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/reference-output/007-multiple-action-chunks-with-includes.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'block0A is not defined', stack: `ReferenceError: block0A is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/reference-output/008-template-string-in-action.jison-ref.json5 b/packages/jison-lex/tests/specs/reference-output/008-template-string-in-action.jison-ref.json5 index e54fa4c0b..1b82862bf 100644 --- a/packages/jison-lex/tests/specs/reference-output/008-template-string-in-action.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/reference-output/008-template-string-in-action.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/reference-output/009-template-string-in-action.jison-ref.json5 b/packages/jison-lex/tests/specs/reference-output/009-template-string-in-action.jison-ref.json5 index e54fa4c0b..1b82862bf 100644 --- a/packages/jison-lex/tests/specs/reference-output/009-template-string-in-action.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/reference-output/009-template-string-in-action.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/reference-output/010-action-code-marker-alternatives.jison-ref.json5 b/packages/jison-lex/tests/specs/reference-output/010-action-code-marker-alternatives.jison-ref.json5 index e54fa4c0b..1b82862bf 100644 --- a/packages/jison-lex/tests/specs/reference-output/010-action-code-marker-alternatives.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/reference-output/010-action-code-marker-alternatives.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/jison-lex/tests/specs/reference-output/011-action-code-marker-alternatives.jison-ref.json5 b/packages/jison-lex/tests/specs/reference-output/011-action-code-marker-alternatives.jison-ref.json5 index e54fa4c0b..1b82862bf 100644 --- a/packages/jison-lex/tests/specs/reference-output/011-action-code-marker-alternatives.jison-ref.json5 +++ b/packages/jison-lex/tests/specs/reference-output/011-action-code-marker-alternatives.jison-ref.json5 @@ -7,10 +7,10 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13673:31) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13673:31) + at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_next [as next] (/regexp-lexer-cjs.js:13744:31) + at Object.lexer_lex [as lex] (/regexp-lexer-cjs.js:13744:31) at Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/Makefile b/packages/lex-parser/Makefile index 5228d549f..3dcf0c549 100644 --- a/packages/lex-parser/Makefile +++ b/packages/lex-parser/Makefile @@ -1,5 +1,5 @@ -JISON_VERSION := $(shell node ../../dist/cli-cjs-es5.js -V 2> /dev/null ) +JISON_VERSION := $(shell node ../../dist/cli-cjs.js -V 2> /dev/null ) ROLLUP = ../../node_modules/.bin/rollup BABEL = ../../node_modules/.bin/babel @@ -10,9 +10,9 @@ ifndef JISON_VERSION JISON = sh ../../node_modules/.bin/jison else ifndef FULL_CODE_COVERAGE - JISON = node ../../dist/cli-cjs-es5.js + JISON = node ../../dist/cli-cjs.js else - JISON = $(NYC) --reporter=lcov -- node ../../dist/cli-cjs-es5.js + JISON = $(NYC) --reporter=lcov -- node ../../dist/cli-cjs.js endif endif diff --git a/packages/lex-parser/dist/lex-parser-cjs-es5.js b/packages/lex-parser/dist/lex-parser-cjs-es5.js index 780cf00f3..770c1ba80 100644 --- a/packages/lex-parser/dist/lex-parser-cjs-es5.js +++ b/packages/lex-parser/dist/lex-parser-cjs-es5.js @@ -2273,30 +2273,32 @@ let parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { - this.$[key] = yyvstack[yysp - 2][key]; - } // if there are any options, add them all, otherwise set options to NULL: - // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: + for (let key in yyvstack[yysp - 2]) { + this.$[key] = yyvstack[yysp - 2][key]; + } // if there are any options, add them all, otherwise set options to NULL: + // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { - this.$.options = yy.options; - break; - } + for (let key in yy.options) { + this.$.options = yy.options; + break; + } - if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: + if (yy.actionInclude) { + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: - if (asrc.trim() !== '') { - this.$.actionInclude = asrc; + if (asrc.trim() !== '') { + this.$.actionInclude = asrc; + } } - } - delete yy.options; - delete yy.actionInclude; - return this.$; + delete yy.options; + delete yy.actionInclude; + return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2437,22 +2439,23 @@ let parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - if (yyvstack[yysp]) { - switch (yyvstack[yysp].type) { - case 'macro': - this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; - break; + if (yyvstack[yysp]) { + switch (yyvstack[yysp].type) { + case 'macro': + this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; + break; - case 'names': - var condition_defs = yyvstack[yysp].names; + case 'names': + let condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; - if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { - yyparser.yyError(rmCommonWS$1` + if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { + yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both EXCLUSIVE ('%x') and INCLUSIVE ('%s'). Pick one, please, e.g.: @@ -2466,39 +2469,39 @@ let parser = { Technical error report: ${yyvstack[yysp].errStr} `); - } + } - this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' - } // and update the `yy.startConditions` hash table as well, so we have a full set - // by the time this parser arrives at the lexer rules in the input-to-parse: + this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' + } // and update the `yy.startConditions` hash table as well, so we have a full set + // by the time this parser arrives at the lexer rules in the input-to-parse: - yy.startConditions = this.$.startConditions; - break; + yy.startConditions = this.$.startConditions; + break; - case 'unknown': - this.$.unknownDecls.push(yyvstack[yysp].body); - break; + case 'unknown': + this.$.unknownDecls.push(yyvstack[yysp].body); + break; - case 'imports': - this.$.importDecls.push(yyvstack[yysp].body); - break; + case 'imports': + this.$.importDecls.push(yyvstack[yysp].body); + break; - case 'codeSection': - this.$.codeSections.push(yyvstack[yysp].body); - break; + case 'codeSection': + this.$.codeSections.push(yyvstack[yysp].body); + break; - default: - yyparser.yyError(rmCommonWS$1` + default: + yyparser.yyError(rmCommonWS$1` Encountered an unsupported definition type: ${yyvstack[yysp].type}. Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} `); - break; + break; + } } } - break; case 9: @@ -2576,17 +2579,19 @@ let parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + let lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 0; // flag as 'inclusive' - } + for (let i = 0, len = lst.length; i < len; i++) { + lst[i][1] = 0; // flag as 'inclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 13: @@ -2611,17 +2616,19 @@ let parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + let lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 1; // flag as 'exclusive' - } + for (let i = 0, len = lst.length; i < len; i++) { + lst[i][1] = 1; // flag as 'exclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 15: @@ -2646,24 +2653,26 @@ let parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); + } + + yy.actionInclude.push(srcCode); } - yy.actionInclude.push(srcCode); + this.$ = null; } - - this.$ = null; break; case 17: @@ -2684,8 +2693,6 @@ let parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -2703,9 +2710,10 @@ let parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1` + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -2718,7 +2726,8 @@ let parser = { Technical error report: ${yyvstack[yysp].errStr} `); - this.$ = null; + this.$ = null; + } break; case 20: @@ -2726,13 +2735,15 @@ let parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + let lst = yyvstack[yysp - 1]; + + for (let i = 0, len = lst.length; i < len; i++) { + yy.options[lst[i][0]] = lst[i][1]; + } - for (var i = 0, len = lst.length; i < len; i++) { - yy.options[lst[i][0]] = lst[i][1]; + this.$ = null; } - - this.$ = null; break; case 21: @@ -2767,40 +2778,42 @@ let parser = { /*! Production:: definition : import_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // check if there are two unvalued options: 'name path' - - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; - if (len === 2 && lst[0][1] === true && lst[1][1] === true) { - // `name path`: - body = { - name: lst[0][0], - path: lst[1][0] - }; - } else if (len <= 2) { - yyparser.yyError(rmCommonWS$1` + { + // check if there are two unvalued options: 'name path' + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; + + if (len === 2 && lst[0][1] === true && lst[1][1] === true) { + // `name path`: + body = { + name: lst[0][0], + path: lst[1][0] + }; + } else if (len <= 2) { + yyparser.yyError(rmCommonWS$1` You did not specify a legal qualifier name and/or file path for the '%import' statement, which must have the format: %import qualifier_name file_path Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); - } else { - yyparser.yyError(rmCommonWS$1` + } else { + yyparser.yyError(rmCommonWS$1` You did specify too many attributes for the '%import' statement, which must have the format: %import qualifier_name file_path Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); - } + } - this.$ = { - type: 'imports', - body: body - }; + this.$ = { + type: 'imports', + body: body + }; + } break; case 24: @@ -2827,52 +2840,54 @@ let parser = { /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) - // check there's only 1 option which is an identifier - - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; - if (len === 1 && lst[0][1] === true) { - // `name`: - name = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1` + { + // check there's only 1 option which is an identifier + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; + + if (len === 1 && lst[0][1] === true) { + // `name`: + name = lst[0][0]; + } else if (len <= 1) { + yyparser.yyError(rmCommonWS$1` You did not specify a legal qualifier name for the '%code' initialization code statement, which must have the format: %code qualifier_name %{...code...%} Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5])} `); - } else { - yyparser.yyError(rmCommonWS$1` + } else { + yyparser.yyError(rmCommonWS$1` You did specify too many attributes for the '%code' initialization code statement, which must have the format: %code qualifier_name %{...code...%} Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5])} `); - } + } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5])} `); - } - - this.$ = { - type: 'codeSection', - body: { - qualifier: name, - include: srcCode } - }; + + this.$ = { + type: 'codeSection', + body: { + qualifier: name, + include: srcCode + } + }; + } break; case 26: @@ -2881,10 +2896,11 @@ let parser = { this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - var end_marker_msg = marker_msg.replace(/\{/g, '}'); - yyparser.yyError(rmCommonWS$1` + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + let end_marker_msg = marker_msg.replace(/\{/g, '}'); + yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) and matching end markers (\`%}\`${end_marker_msg}). Expected format: @@ -2897,6 +2913,7 @@ let parser = { Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3068,24 +3085,26 @@ let parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); + } + + yy.actionInclude.push(srcCode); } - yy.actionInclude.push(srcCode); + this.$ = yyvstack[yysp - 3]; } - - this.$ = yyvstack[yysp - 3]; break; case 42: @@ -3103,9 +3122,9 @@ let parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1` + { + let start_marker = yyvstack[yysp - 1].trim(); + yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -3114,7 +3133,8 @@ let parser = { Technical error report: ${yyvstack[yysp].errStr} `); - this.$ = yyvstack[yysp - 2]; + this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3122,15 +3142,16 @@ let parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error - // is more probably due to indenting the rule regex, rather than an error - // in writing the action code block: + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error + // is more probably due to indenting the rule regex, rather than an error + // in writing the action code block: - console.error("*** error! marker:", start_marker); + console.error("*** error! marker:", start_marker); - if (start_marker.indexOf('{') >= 0) { - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1` + if (start_marker.indexOf('{') >= 0) { + let marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -3143,8 +3164,8 @@ let parser = { Technical error report: ${yyvstack[yysp].errStr} `); - } else { - yyparser.yyError(rmCommonWS$1` + } else { + yyparser.yyError(rmCommonWS$1` There's probably an error in one or more of your lexer regex rules. Did you perhaps indent the rule regex? Note that all rule regexes MUST start at the start of the line, i.e. text column 1. Indented text @@ -3157,9 +3178,10 @@ let parser = { Technical error report: ${yyvstack[yysp].errStr} `); - } + } - this.$ = yyvstack[yysp - 2]; + this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3308,19 +3330,21 @@ let parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3])} `); - } + } - this.$ = [yyvstack[yysp - 3], srcCode]; + this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3328,28 +3352,29 @@ let parser = { // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. - // - // Note/Optimization: - // there's no need for braces in the generated expression when we can - // already see the given action is an identifier string or something else - // that's a sure simple thing for a JavaScript `return` statement to carry. - // By doing this, we simplify the token return replacement code replacement - // process which will be applied to the parsed lexer before its code - // will be generated by JISON. - - if (/^[^\r\n;\/]+$/.test(srcCode)) { - srcCode = 'return ' + srcCode; - } else { - srcCode = 'return (' + srcCode + '\n)'; - } + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. + // + // Note/Optimization: + // there's no need for braces in the generated expression when we can + // already see the given action is an identifier string or something else + // that's a sure simple thing for a JavaScript `return` statement to carry. + // By doing this, we simplify the token return replacement code replacement + // process which will be applied to the parsed lexer before its code + // will be generated by JISON. + + if (/^[^\r\n;\/]+$/.test(srcCode)) { + srcCode = 'return ' + srcCode; + } else { + srcCode = 'return (' + srcCode + '\n)'; + } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} # NOTE that the arrow action automatically wraps the action code @@ -3359,9 +3384,10 @@ let parser = { Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3])} `); - } + } - this.$ = [yyvstack[yysp - 3], srcCode]; + this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3575,14 +3601,15 @@ let parser = { /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; // Validate the given condition state: when it isn't known, print an error message - // accordingly: + { + // rewrite + accept star '*' as name + check if we allow empty list? + this.$ = yyvstack[yysp - 2].map(function (el) { + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message + // accordingly: - if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { - yyparser.yyError(rmCommonWS$1` + if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { + yyparser.yyError(rmCommonWS$1` You specified an unknown lexer condition state '${name}'. Is this a typo or did you forget to include this one in the '%s' and '%x' inclusive and exclusive condition state sets specifications at the top of @@ -3598,12 +3625,12 @@ let parser = { Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp])} `); - } - - return name; - }); // '<' '*' '>' - // { $$ = ['*']; } + } + return name; + }); // '<' '*' '>' + // { $$ = ['*']; } + } break; case 74: @@ -3611,12 +3638,13 @@ let parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { - return el[0]; - }); - yyparser.yyError(rmCommonWS$1` + { + // rewrite + accept star '*' as name + check if we allow empty list? + let lst = yyvstack[yysp - 1].map(function (el) { + return el[0]; + }); + yyparser.yyError(rmCommonWS$1` Seems you did not correctly terminate the start condition set <${lst.join(',')},???> with a terminating '>' @@ -3627,72 +3655,74 @@ let parser = { Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: /*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // Detect if the regex ends with a pure (Unicode) word; - // we *do* consider escaped characters which are 'alphanumeric' - // to be equivalent to their non-escaped version, hence these are - // all valid 'words' for the 'easy keyword rules' option: - // - // - hello_kitty - // - γεια_σου_γατούλα - // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 - // - // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 - // - // As we only check the *tail*, we also accept these as - // 'easy keywords': - // - // - %options - // - %foo-bar - // - +++a:b:c1 - // - // Note the dash in that last example: there the code will consider - // `bar` to be the keyword, which is fine with us as we're only - // interested in the trailing boundary and patching that one for - // the `easy_keyword_rules` option. - this.$ = yyvstack[yysp]; + { + // Detect if the regex ends with a pure (Unicode) word; + // we *do* consider escaped characters which are 'alphanumeric' + // to be equivalent to their non-escaped version, hence these are + // all valid 'words' for the 'easy keyword rules' option: + // + // - hello_kitty + // - γεια_σου_γατούλα + // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 + // + // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 + // + // As we only check the *tail*, we also accept these as + // 'easy keywords': + // + // - %options + // - %foo-bar + // - +++a:b:c1 + // + // Note the dash in that last example: there the code will consider + // `bar` to be the keyword, which is fine with us as we're only + // interested in the trailing boundary and patching that one for + // the `easy_keyword_rules` option. + this.$ = yyvstack[yysp]; - if (yy.options.easy_keyword_rules) { - // We need to 'protect' `eval` here as keywords are allowed - // to contain double-quotes and other leading cruft. - // `eval` *does* gobble some escapes (such as `\b`) but - // we protect against that through a simple replace regex: - // we're not interested in the special escapes' exact value - // anyway. - // It will also catch escaped escapes (`\\`), which are not - // word characters either, so no need to worry about - // `eval(str)` 'correctly' converting convoluted constructs - // like '\\\\\\\\\\b' in here. - this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); - - try { - // Convert Unicode escapes and other escapes to their literal characters - // BEFORE we go and check whether this item is subject to the - // `easy_keyword_rules` option. - this.$ = JSON.parse('"' + this.$ + '"'); - } catch (ex) { - yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: - - this.$ = '.'; - } // a 'keyword' starts with an alphanumeric character, - // followed by zero or more alphanumerics or digits: - - - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); - - if (XRegExp__default['default'].match(this.$, re)) { - this.$ = yyvstack[yysp] + "\\b"; - } else { - this.$ = yyvstack[yysp]; + if (yy.options.easy_keyword_rules) { + // We need to 'protect' `eval` here as keywords are allowed + // to contain double-quotes and other leading cruft. + // `eval` *does* gobble some escapes (such as `\b`) but + // we protect against that through a simple replace regex: + // we're not interested in the special escapes' exact value + // anyway. + // It will also catch escaped escapes (`\\`), which are not + // word characters either, so no need to worry about + // `eval(str)` 'correctly' converting convoluted constructs + // like '\\\\\\\\\\b' in here. + this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); + + try { + // Convert Unicode escapes and other escapes to their literal characters + // BEFORE we go and check whether this item is subject to the + // `easy_keyword_rules` option. + this.$ = JSON.parse('"' + this.$ + '"'); + } catch (ex) { + yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: + + this.$ = '.'; + } // a 'keyword' starts with an alphanumeric character, + // followed by zero or more alphanumerics or digits: + + + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + + if (XRegExp__default['default'].match(this.$, re)) { + this.$ = yyvstack[yysp] + "\\b"; + } else { + this.$ = yyvstack[yysp]; + } } } - break; case 76: @@ -3926,10 +3956,12 @@ let parser = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; - this.$ = encodeRegexLiteralStr(s, edge); + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; + this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -3937,31 +3969,34 @@ let parser = { // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; - this.$ = encodeRegexLiteralStr(s); + { + let s = yyvstack[yysp]; + this.$ = encodeRegexLiteralStr(s); + } break; case 113: /*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal behaviour under the given circumstances, i.e. parser context: - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { - yyparser.yyError(rmCommonWS$1` + { + // validate that this is legal behaviour under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { + yyparser.yyError(rmCommonWS$1` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4])} `); - } + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { - return opt[0]; - }); - optlist.push(yyvstack[yysp][0]); - yyparser.yyError(rmCommonWS$1` + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { + let optlist = yyvstack[yysp - 2].map(function (opt) { + return opt[0]; + }); + optlist.push(yyvstack[yysp][0]); + yyparser.yyError(rmCommonWS$1` You may not separate entries in a ${yy.__options_category_description__} statement using commas. Use whitespace instead, e.g.: @@ -3970,10 +4005,11 @@ let parser = { Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4])} `); - } + } - this.$ = yyvstack[yysp - 2]; - this.$.push(yyvstack[yysp]); + this.$ = yyvstack[yysp - 2]; + this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4053,13 +4089,14 @@ let parser = { this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1` + yyparser.yyError(rmCommonWS$1` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. Erroneous area: @@ -4068,28 +4105,30 @@ let parser = { Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: /*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - - if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { - this.$ = mkIdentifier$1(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; - // if not, report an error as we don't want confusion due to - // typos and/or garbage input here producing something that - // is usable from a machine perspective. - - if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { + this.$ = mkIdentifier$1(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; + // if not, report an error as we don't want confusion due to + // typos and/or garbage input here producing something that + // is usable from a machine perspective. + + if (!isLegalIdentifierInput$1(yyvstack[yysp])) { + let with_value_msg = ' (with optional value assignment)'; + + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1` + yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -4098,29 +4137,30 @@ let parser = { Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); + } + } else { + this.$ = yyvstack[yysp]; } - } else { - this.$ = yyvstack[yysp]; } - break; case 121: /*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { - this.$ = yyvstack[yysp]; - } else { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { + this.$ = yyvstack[yysp]; + } else { + let with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1` + yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -4129,8 +4169,8 @@ let parser = { Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); + } } - break; case 122: @@ -4162,22 +4202,24 @@ let parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} `); + } } - } - this.$ = srcCode; + this.$ = srcCode; + } break; case 126: @@ -4220,25 +4262,27 @@ let parser = { // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); - } - } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) - // we append those protective double newlines right now, as the calling site - // won't do it for us: + } + } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) + // we append those protective double newlines right now, as the calling site + // won't do it for us: - this.$ = '\n\n' + srcCode + '\n\n'; + this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4246,9 +4290,9 @@ let parser = { // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1` + { + let start_marker = yyvstack[yysp - 1].trim(); + yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -4257,7 +4301,8 @@ let parser = { Technical error report: ${yyvstack[yysp].errStr} `); - this.$ = ''; + this.$ = ''; + } break; case 133: @@ -4274,17 +4319,18 @@ let parser = { /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) - // check if there is only 1 unvalued options: 'path' - - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; - if (len === 1 && lst[0][1] === true) { - // `path`: - path = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1` + { + // check if there is only 1 unvalued options: 'path' + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; + + if (len === 1 && lst[0][1] === true) { + // `path`: + path = lst[0][0]; + } else if (len <= 1) { + yyparser.yyError(rmCommonWS$1` You did not specify a legal file path for the '%include' statement, which must have the format: %include file_path @@ -4294,8 +4340,8 @@ let parser = { Technical error report: ${$error.errStr} `); - } else { - yyparser.yyError(rmCommonWS$1` + } else { + yyparser.yyError(rmCommonWS$1` You did specify too many attributes for the '%include' statement, which must have the format: %include file_path @@ -4305,28 +4351,29 @@ let parser = { Technical error report: ${$error.errStr} `); - } // **Aside**: And no, we don't support nested '%include'! + } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { - encoding: 'utf-8' - }); - var srcCode = trimActionCode$1(fileContent); + let fileContent = fs__default['default'].readFileSync(path, { + encoding: 'utf-8' + }); + let srcCode = trimActionCode$1(fileContent); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, this._$, yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(this._$)} `); + } } - } - this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -7634,19 +7681,21 @@ var lexer = function () { /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; - var l = scanRegExp(yy_.yytext); + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); - yy_.yytext = yy_.yytext[0]; - } + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - return 35; + return 35; + } case 10: /*! Conditions:: action */ @@ -7750,71 +7799,73 @@ var lexer = function () { /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - yy.include_command_allowed = false; - this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - - var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + + let marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr + /* @ Start Of File */ + || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - var prevEnd = 0; - var endMarkerIndex; + let remaining = this.lookAhead(); + let prevEnd = 0; + let endMarkerIndex; - for (;;) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + for (;;) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; - } + return 24; + } - break; - } // Allow the start marker to be re-matched by the generated lexer rule regex: + break; + } // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; - } + if (atSOL) { + return 22; + } - return 25; + return 25; + } case 20: /*! Conditions:: rules macro INITIAL */ @@ -7847,41 +7898,43 @@ var lexer = function () { /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); - - this.pushState('action'); // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - - var la = this.lookAhead(); - - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser - } + { + yy.depth = 0; + yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); + + this.pushState('action'); // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - return 25; + return 25; + } case 24: /*! Conditions:: rules */ @@ -8038,32 +8091,34 @@ var lexer = function () { /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); - yy_.yytext = v; - } + { + let m = this.matches; + yy_.yytext = NaN; - return 43; + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + yy_.yytext = v; + } + + return 43; + } case 70: /*! Conditions:: rules macro INITIAL */ @@ -8111,27 +8166,29 @@ var lexer = function () { /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; - yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; - this.pushState('action'); // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - - this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + { + yy.depth = 0; + yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr + /* @ Start Of File */ + || precedingStr === '\n'; + this.pushState('action'); // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + + this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + + if (atSOL) { + return 22; + } - if (atSOL) { - return 22; + return 25; } - return 25; - case 81: /*! Conditions:: INITIAL rules code */ @@ -8250,49 +8307,55 @@ var lexer = function () { /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -8305,7 +8368,8 @@ var lexer = function () { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ @@ -8786,9 +8850,9 @@ var lexer = function () { } } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: lexer.setupDelimitedActionChunkLexerRegex = function lexer__setupDelimitedActionChunkLexerRegex(marker) { @@ -8796,8 +8860,8 @@ var lexer = function () { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let doNotPatch = marker === '{'; + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -8805,7 +8869,7 @@ var lexer = function () { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -8815,11 +8879,11 @@ var lexer = function () { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; // Must we still locate the rule to patch or have we done + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? // // WARNING: our cache/patch must live beyond the current lexer+parser invocation: @@ -8834,14 +8898,14 @@ var lexer = function () { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { spec.__action_chunk_rule_idx = i; @@ -8896,11 +8960,11 @@ var lexer = function () { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$1 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; // see also: +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$1 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: // - https://en.wikipedia.org/wiki/C0_and_C1_control_codes // - https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-escapes-in-regular-expressions // - https://kangax.github.io/compat-table/es6/#test-RegExp_y_and_u_flags @@ -8937,11 +9001,11 @@ const codeCvtTable = { // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -8951,7 +9015,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -8960,10 +9024,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': @@ -8977,7 +9041,7 @@ function encodeRegexLiteralStr(s, edge) { continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; @@ -8993,7 +9057,7 @@ function encodeRegexLiteralStr(s, edge) { // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { @@ -9019,7 +9083,7 @@ function encodeRegexLiteralStr(s, edge) { if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; @@ -9027,7 +9091,7 @@ function encodeRegexLiteralStr(s, edge) { if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; @@ -9035,7 +9099,7 @@ function encodeRegexLiteralStr(s, edge) { if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; @@ -9043,7 +9107,7 @@ function encodeRegexLiteralStr(s, edge) { if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; @@ -9051,7 +9115,7 @@ function encodeRegexLiteralStr(s, edge) { if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -9066,24 +9130,24 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; @@ -9118,7 +9182,7 @@ function parseValue(v) { if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; diff --git a/packages/lex-parser/dist/lex-parser-cjs.js b/packages/lex-parser/dist/lex-parser-cjs.js index 19f3d14df..f694dd2ff 100644 --- a/packages/lex-parser/dist/lex-parser-cjs.js +++ b/packages/lex-parser/dist/lex-parser-cjs.js @@ -2560,20 +2560,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2583,6 +2584,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2732,6 +2734,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2740,9 +2743,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -2789,6 +2792,7 @@ case 8: break; } } + } break; case 9: @@ -2873,8 +2877,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -2882,6 +2887,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -2912,8 +2918,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -2921,6 +2928,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -2951,9 +2959,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -2965,6 +2974,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -2990,8 +3000,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3012,8 +3020,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3028,6 +3037,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3038,11 +3048,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3087,10 +3099,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3119,6 +3132,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3152,10 +3166,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3177,8 +3192,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3194,6 +3209,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3205,9 +3221,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3221,6 +3238,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3433,9 +3451,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3447,6 +3466,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3470,8 +3490,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3482,6 +3502,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3492,13 +3513,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3528,6 +3550,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3693,8 +3716,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3704,6 +3728,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3714,7 +3739,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3732,7 +3758,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3747,6 +3773,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3992,9 +4019,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4022,6 +4050,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4033,8 +4062,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4049,6 +4079,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4059,6 +4090,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4113,13 +4145,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4407,10 +4440,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4421,8 +4456,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4433,6 +4470,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4443,7 +4481,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4460,6 +4498,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4555,7 +4594,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4568,6 +4608,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4578,6 +4619,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -4586,7 +4628,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4603,6 +4645,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4613,11 +4656,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4631,6 +4675,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4674,9 +4719,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4687,6 +4733,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4738,9 +4785,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4754,6 +4802,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4764,8 +4813,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4776,6 +4825,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -4799,10 +4849,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -4831,11 +4882,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -4847,6 +4898,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -9996,21 +10048,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10104,55 +10157,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10160,24 +10213,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10205,44 +10259,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10367,38 +10422,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10438,29 +10494,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10564,49 +10621,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10620,7 +10684,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11197,9 +11262,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11208,9 +11273,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11218,7 +11283,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11228,11 +11293,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11248,15 +11313,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11316,11 +11381,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$1 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$1 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11361,11 +11426,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11375,7 +11440,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11384,10 +11449,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11397,7 +11462,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11410,7 +11475,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11432,35 +11497,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11474,19 +11539,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11517,7 +11582,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/lex-parser/dist/lex-parser-es6.js b/packages/lex-parser/dist/lex-parser-es6.js index 802479451..39c409fbd 100644 --- a/packages/lex-parser/dist/lex-parser-es6.js +++ b/packages/lex-parser/dist/lex-parser-es6.js @@ -2548,20 +2548,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2571,6 +2572,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2720,6 +2722,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2728,9 +2731,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -2777,6 +2780,7 @@ case 8: break; } } + } break; case 9: @@ -2861,8 +2865,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -2870,6 +2875,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -2900,8 +2906,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -2909,6 +2916,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -2939,9 +2947,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -2953,6 +2962,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -2978,8 +2988,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3000,8 +3008,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3016,6 +3025,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3026,11 +3036,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3075,10 +3087,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3107,6 +3120,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -3140,10 +3154,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3165,8 +3180,8 @@ case 25: `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3182,6 +3197,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -3193,9 +3209,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3209,6 +3226,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3421,9 +3439,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3435,6 +3454,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3458,8 +3478,8 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3470,6 +3490,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3480,13 +3501,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3516,6 +3538,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3681,8 +3704,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3692,6 +3716,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3702,7 +3727,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3720,7 +3746,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3735,6 +3761,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3980,9 +4007,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4010,6 +4038,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4021,8 +4050,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4037,6 +4067,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4047,6 +4078,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4101,13 +4133,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp('\\w[\\w\\d]*$'); + let re = new XRegExp('\\w[\\w\\d]*$'); if (XRegExp.match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4395,10 +4428,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4409,8 +4444,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4421,6 +4458,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4431,7 +4469,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4448,6 +4486,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4543,7 +4582,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4556,6 +4596,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4566,6 +4607,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -4574,7 +4616,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4591,6 +4633,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4601,11 +4644,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4619,6 +4663,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4662,9 +4707,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4675,6 +4721,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -4726,9 +4773,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4742,6 +4790,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4752,8 +4801,8 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4764,6 +4813,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -4787,10 +4837,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -4819,11 +4870,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -4835,6 +4886,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -9984,21 +10036,22 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10092,55 +10145,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10148,24 +10201,25 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10193,44 +10247,45 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10355,38 +10410,39 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10426,29 +10482,30 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10552,49 +10609,56 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10608,7 +10672,8 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11185,9 +11250,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11196,9 +11261,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11206,7 +11271,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11216,11 +11281,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11236,15 +11301,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11304,11 +11369,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS$1 = helpers.rmCommonWS; -var checkActionBlock$1 = helpers.checkActionBlock; -var mkIdentifier$1 = helpers.mkIdentifier; -var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; -var trimActionCode$1 = helpers.trimActionCode; +const rmCommonWS$1 = helpers.rmCommonWS; +const checkActionBlock$1 = helpers.checkActionBlock; +const mkIdentifier$1 = helpers.mkIdentifier; +const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; +const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11349,11 +11414,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11363,7 +11428,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11372,10 +11437,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11385,7 +11450,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11398,7 +11463,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11420,35 +11485,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11462,19 +11527,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11505,7 +11570,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/lex-parser/dist/lex-parser-umd-es5.js b/packages/lex-parser/dist/lex-parser-umd-es5.js index 4b71483df..abf2ba267 100644 --- a/packages/lex-parser/dist/lex-parser-umd-es5.js +++ b/packages/lex-parser/dist/lex-parser-umd-es5.js @@ -2260,30 +2260,32 @@ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { - this.$[key] = yyvstack[yysp - 2][key]; - } // if there are any options, add them all, otherwise set options to NULL: - // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: + for (let key in yyvstack[yysp - 2]) { + this.$[key] = yyvstack[yysp - 2][key]; + } // if there are any options, add them all, otherwise set options to NULL: + // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { - this.$.options = yy.options; - break; - } + for (let key in yy.options) { + this.$.options = yy.options; + break; + } - if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: + if (yy.actionInclude) { + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: - if (asrc.trim() !== '') { - this.$.actionInclude = asrc; + if (asrc.trim() !== '') { + this.$.actionInclude = asrc; + } } - } - delete yy.options; - delete yy.actionInclude; - return this.$; + delete yy.options; + delete yy.actionInclude; + return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2424,22 +2426,23 @@ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - this.$ = yyvstack[yysp - 1]; + { + this.$ = yyvstack[yysp - 1]; - if (yyvstack[yysp]) { - switch (yyvstack[yysp].type) { - case 'macro': - this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; - break; + if (yyvstack[yysp]) { + switch (yyvstack[yysp].type) { + case 'macro': + this.$.macros[yyvstack[yysp].name] = yyvstack[yysp].body; + break; - case 'names': - var condition_defs = yyvstack[yysp].names; + case 'names': + let condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; - if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { - yyparser.yyError(rmCommonWS$1` + if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { + yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both EXCLUSIVE ('%x') and INCLUSIVE ('%s'). Pick one, please, e.g.: @@ -2453,39 +2456,39 @@ Technical error report: ${yyvstack[yysp].errStr} `); - } + } - this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' - } // and update the `yy.startConditions` hash table as well, so we have a full set - // by the time this parser arrives at the lexer rules in the input-to-parse: + this.$.startConditions[name] = condition_defs[i][1]; // flag as 'exclusive'/'inclusive' + } // and update the `yy.startConditions` hash table as well, so we have a full set + // by the time this parser arrives at the lexer rules in the input-to-parse: - yy.startConditions = this.$.startConditions; - break; + yy.startConditions = this.$.startConditions; + break; - case 'unknown': - this.$.unknownDecls.push(yyvstack[yysp].body); - break; + case 'unknown': + this.$.unknownDecls.push(yyvstack[yysp].body); + break; - case 'imports': - this.$.importDecls.push(yyvstack[yysp].body); - break; + case 'imports': + this.$.importDecls.push(yyvstack[yysp].body); + break; - case 'codeSection': - this.$.codeSections.push(yyvstack[yysp].body); - break; + case 'codeSection': + this.$.codeSections.push(yyvstack[yysp].body); + break; - default: - yyparser.yyError(rmCommonWS$1` + default: + yyparser.yyError(rmCommonWS$1` Encountered an unsupported definition type: ${yyvstack[yysp].type}. Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp])} `); - break; + break; + } } } - break; case 9: @@ -2563,17 +2566,19 @@ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + let lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 0; // flag as 'inclusive' - } + for (let i = 0, len = lst.length; i < len; i++) { + lst[i][1] = 0; // flag as 'inclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 13: @@ -2598,17 +2603,19 @@ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + let lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { - lst[i][1] = 1; // flag as 'exclusive' - } + for (let i = 0, len = lst.length; i < len; i++) { + lst[i][1] = 1; // flag as 'exclusive' + } - this.$ = { - type: 'names', - names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 + this.$ = { + type: 'names', + names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 - }; + }; + } break; case 15: @@ -2633,24 +2640,26 @@ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); + } + + yy.actionInclude.push(srcCode); } - yy.actionInclude.push(srcCode); + this.$ = null; } - - this.$ = null; break; case 17: @@ -2671,8 +2680,6 @@ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -2690,9 +2697,10 @@ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1` + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -2705,7 +2713,8 @@ Technical error report: ${yyvstack[yysp].errStr} `); - this.$ = null; + this.$ = null; + } break; case 20: @@ -2713,13 +2722,15 @@ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; + { + let lst = yyvstack[yysp - 1]; + + for (let i = 0, len = lst.length; i < len; i++) { + yy.options[lst[i][0]] = lst[i][1]; + } - for (var i = 0, len = lst.length; i < len; i++) { - yy.options[lst[i][0]] = lst[i][1]; + this.$ = null; } - - this.$ = null; break; case 21: @@ -2754,40 +2765,42 @@ /*! Production:: definition : import_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // check if there are two unvalued options: 'name path' - - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; - if (len === 2 && lst[0][1] === true && lst[1][1] === true) { - // `name path`: - body = { - name: lst[0][0], - path: lst[1][0] - }; - } else if (len <= 2) { - yyparser.yyError(rmCommonWS$1` + { + // check if there are two unvalued options: 'name path' + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; + + if (len === 2 && lst[0][1] === true && lst[1][1] === true) { + // `name path`: + body = { + name: lst[0][0], + path: lst[1][0] + }; + } else if (len <= 2) { + yyparser.yyError(rmCommonWS$1` You did not specify a legal qualifier name and/or file path for the '%import' statement, which must have the format: %import qualifier_name file_path Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); - } else { - yyparser.yyError(rmCommonWS$1` + } else { + yyparser.yyError(rmCommonWS$1` You did specify too many attributes for the '%import' statement, which must have the format: %import qualifier_name file_path Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); - } + } - this.$ = { - type: 'imports', - body: body - }; + this.$ = { + type: 'imports', + body: body + }; + } break; case 24: @@ -2814,52 +2827,54 @@ /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) - // check there's only 1 option which is an identifier - - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; - if (len === 1 && lst[0][1] === true) { - // `name`: - name = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1` + { + // check there's only 1 option which is an identifier + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; + + if (len === 1 && lst[0][1] === true) { + // `name`: + name = lst[0][0]; + } else if (len <= 1) { + yyparser.yyError(rmCommonWS$1` You did not specify a legal qualifier name for the '%code' initialization code statement, which must have the format: %code qualifier_name %{...code...%} Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5])} `); - } else { - yyparser.yyError(rmCommonWS$1` + } else { + yyparser.yyError(rmCommonWS$1` You did specify too many attributes for the '%code' initialization code statement, which must have the format: %code qualifier_name %{...code...%} Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 4], yylstack[yysp - 5])} `); - } + } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 5])} `); - } - - this.$ = { - type: 'codeSection', - body: { - qualifier: name, - include: srcCode } - }; + + this.$ = { + type: 'codeSection', + body: { + qualifier: name, + include: srcCode + } + }; + } break; case 26: @@ -2868,10 +2883,11 @@ this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - var end_marker_msg = marker_msg.replace(/\{/g, '}'); - yyparser.yyError(rmCommonWS$1` + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + let end_marker_msg = marker_msg.replace(/\{/g, '}'); + yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) and matching end markers (\`%}\`${end_marker_msg}). Expected format: @@ -2884,6 +2900,7 @@ Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3055,24 +3072,26 @@ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); + } + + yy.actionInclude.push(srcCode); } - yy.actionInclude.push(srcCode); + this.$ = yyvstack[yysp - 3]; } - - this.$ = yyvstack[yysp - 3]; break; case 42: @@ -3090,9 +3109,9 @@ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1` + { + let start_marker = yyvstack[yysp - 1].trim(); + yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -3101,7 +3120,8 @@ Technical error report: ${yyvstack[yysp].errStr} `); - this.$ = yyvstack[yysp - 2]; + this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3109,15 +3129,16 @@ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error - // is more probably due to indenting the rule regex, rather than an error - // in writing the action code block: + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error + // is more probably due to indenting the rule regex, rather than an error + // in writing the action code block: - console.error("*** error! marker:", start_marker); + console.error("*** error! marker:", start_marker); - if (start_marker.indexOf('{') >= 0) { - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1` + if (start_marker.indexOf('{') >= 0) { + let marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned at the start of a line to be accepted: *indented* action code blocks @@ -3130,8 +3151,8 @@ Technical error report: ${yyvstack[yysp].errStr} `); - } else { - yyparser.yyError(rmCommonWS$1` + } else { + yyparser.yyError(rmCommonWS$1` There's probably an error in one or more of your lexer regex rules. Did you perhaps indent the rule regex? Note that all rule regexes MUST start at the start of the line, i.e. text column 1. Indented text @@ -3144,9 +3165,10 @@ Technical error report: ${yyvstack[yysp].errStr} `); - } + } - this.$ = yyvstack[yysp - 2]; + this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3295,19 +3317,21 @@ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3])} `); - } + } - this.$ = [yyvstack[yysp - 3], srcCode]; + this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3315,28 +3339,29 @@ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. - // - // Note/Optimization: - // there's no need for braces in the generated expression when we can - // already see the given action is an identifier string or something else - // that's a sure simple thing for a JavaScript `return` statement to carry. - // By doing this, we simplify the token return replacement code replacement - // process which will be applied to the parsed lexer before its code - // will be generated by JISON. - - if (/^[^\r\n;\/]+$/.test(srcCode)) { - srcCode = 'return ' + srcCode; - } else { - srcCode = 'return (' + srcCode + '\n)'; - } + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. + // + // Note/Optimization: + // there's no need for braces in the generated expression when we can + // already see the given action is an identifier string or something else + // that's a sure simple thing for a JavaScript `return` statement to carry. + // By doing this, we simplify the token return replacement code replacement + // process which will be applied to the parsed lexer before its code + // will be generated by JISON. + + if (/^[^\r\n;\/]+$/.test(srcCode)) { + srcCode = 'return ' + srcCode; + } else { + srcCode = 'return (' + srcCode + '\n)'; + } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} # NOTE that the arrow action automatically wraps the action code @@ -3346,9 +3371,10 @@ Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 3])} `); - } + } - this.$ = [yyvstack[yysp - 3], srcCode]; + this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3562,14 +3588,15 @@ /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; // Validate the given condition state: when it isn't known, print an error message - // accordingly: + { + // rewrite + accept star '*' as name + check if we allow empty list? + this.$ = yyvstack[yysp - 2].map(function (el) { + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message + // accordingly: - if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { - yyparser.yyError(rmCommonWS$1` + if (name !== '*' && name !== 'INITIAL' && !(name in yy.startConditions)) { + yyparser.yyError(rmCommonWS$1` You specified an unknown lexer condition state '${name}'. Is this a typo or did you forget to include this one in the '%s' and '%x' inclusive and exclusive condition state sets specifications at the top of @@ -3585,12 +3612,12 @@ Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp])} `); - } - - return name; - }); // '<' '*' '>' - // { $$ = ['*']; } + } + return name; + }); // '<' '*' '>' + // { $$ = ['*']; } + } break; case 74: @@ -3598,12 +3625,13 @@ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 2]; this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) - // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { - return el[0]; - }); - yyparser.yyError(rmCommonWS$1` + { + // rewrite + accept star '*' as name + check if we allow empty list? + let lst = yyvstack[yysp - 1].map(function (el) { + return el[0]; + }); + yyparser.yyError(rmCommonWS$1` Seems you did not correctly terminate the start condition set <${lst.join(',')},???> with a terminating '>' @@ -3614,72 +3642,74 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: /*! Production:: regex : nonempty_regex_list */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // Detect if the regex ends with a pure (Unicode) word; - // we *do* consider escaped characters which are 'alphanumeric' - // to be equivalent to their non-escaped version, hence these are - // all valid 'words' for the 'easy keyword rules' option: - // - // - hello_kitty - // - γεια_σου_γατούλα - // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 - // - // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 - // - // As we only check the *tail*, we also accept these as - // 'easy keywords': - // - // - %options - // - %foo-bar - // - +++a:b:c1 - // - // Note the dash in that last example: there the code will consider - // `bar` to be the keyword, which is fine with us as we're only - // interested in the trailing boundary and patching that one for - // the `easy_keyword_rules` option. - this.$ = yyvstack[yysp]; + { + // Detect if the regex ends with a pure (Unicode) word; + // we *do* consider escaped characters which are 'alphanumeric' + // to be equivalent to their non-escaped version, hence these are + // all valid 'words' for the 'easy keyword rules' option: + // + // - hello_kitty + // - γεια_σου_γατούλα + // - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1 + // + // http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914 + // + // As we only check the *tail*, we also accept these as + // 'easy keywords': + // + // - %options + // - %foo-bar + // - +++a:b:c1 + // + // Note the dash in that last example: there the code will consider + // `bar` to be the keyword, which is fine with us as we're only + // interested in the trailing boundary and patching that one for + // the `easy_keyword_rules` option. + this.$ = yyvstack[yysp]; - if (yy.options.easy_keyword_rules) { - // We need to 'protect' `eval` here as keywords are allowed - // to contain double-quotes and other leading cruft. - // `eval` *does* gobble some escapes (such as `\b`) but - // we protect against that through a simple replace regex: - // we're not interested in the special escapes' exact value - // anyway. - // It will also catch escaped escapes (`\\`), which are not - // word characters either, so no need to worry about - // `eval(str)` 'correctly' converting convoluted constructs - // like '\\\\\\\\\\b' in here. - this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); - - try { - // Convert Unicode escapes and other escapes to their literal characters - // BEFORE we go and check whether this item is subject to the - // `easy_keyword_rules` option. - this.$ = JSON.parse('"' + this.$ + '"'); - } catch (ex) { - yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: - - this.$ = '.'; - } // a 'keyword' starts with an alphanumeric character, - // followed by zero or more alphanumerics or digits: - - - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); - - if (XRegExp__default['default'].match(this.$, re)) { - this.$ = yyvstack[yysp] + "\\b"; - } else { - this.$ = yyvstack[yysp]; + if (yy.options.easy_keyword_rules) { + // We need to 'protect' `eval` here as keywords are allowed + // to contain double-quotes and other leading cruft. + // `eval` *does* gobble some escapes (such as `\b`) but + // we protect against that through a simple replace regex: + // we're not interested in the special escapes' exact value + // anyway. + // It will also catch escaped escapes (`\\`), which are not + // word characters either, so no need to worry about + // `eval(str)` 'correctly' converting convoluted constructs + // like '\\\\\\\\\\b' in here. + this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-7]/g, '.'); + + try { + // Convert Unicode escapes and other escapes to their literal characters + // BEFORE we go and check whether this item is subject to the + // `easy_keyword_rules` option. + this.$ = JSON.parse('"' + this.$ + '"'); + } catch (ex) { + yyparser.warn('easy-keyword-rule FAIL on eval: ', ex); // make the next keyword test fail: + + this.$ = '.'; + } // a 'keyword' starts with an alphanumeric character, + // followed by zero or more alphanumerics or digits: + + + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + + if (XRegExp__default['default'].match(this.$, re)) { + this.$ = yyvstack[yysp] + "\\b"; + } else { + this.$ = yyvstack[yysp]; + } } } - break; case 76: @@ -3913,10 +3943,12 @@ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; - this.$ = encodeRegexLiteralStr(s, edge); + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; + this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -3924,31 +3956,34 @@ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; - this.$ = encodeRegexLiteralStr(s); + { + let s = yyvstack[yysp]; + this.$ = encodeRegexLiteralStr(s); + } break; case 113: /*! Production:: option_list : option_list "," option */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal behaviour under the given circumstances, i.e. parser context: - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { - yyparser.yyError(rmCommonWS$1` + { + // validate that this is legal behaviour under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { + yyparser.yyError(rmCommonWS$1` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp]), yylstack[yysp - 4])} `); - } + } - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { - return opt[0]; - }); - optlist.push(yyvstack[yysp][0]); - yyparser.yyError(rmCommonWS$1` + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { + let optlist = yyvstack[yysp - 2].map(function (opt) { + return opt[0]; + }); + optlist.push(yyvstack[yysp][0]); + yyparser.yyError(rmCommonWS$1` You may not separate entries in a ${yy.__options_category_description__} statement using commas. Use whitespace instead, e.g.: @@ -3957,10 +3992,11 @@ Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp - 1], yylstack[yysp - 2]), yylstack[yysp - 4])} `); - } + } - this.$ = yyvstack[yysp - 2]; - this.$.push(yyvstack[yysp]); + this.$ = yyvstack[yysp - 2]; + this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4040,13 +4076,14 @@ this.$ = yyvstack[yysp - 1]; this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1` + yyparser.yyError(rmCommonWS$1` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. Erroneous area: @@ -4055,28 +4092,30 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: /*! Production:: option_name : option_value */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - - if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { - this.$ = mkIdentifier$1(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; - // if not, report an error as we don't want confusion due to - // typos and/or garbage input here producing something that - // is usable from a machine perspective. - - if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { + this.$ = mkIdentifier$1(yyvstack[yysp]); // check if the transformation is obvious & trivial to humans; + // if not, report an error as we don't want confusion due to + // typos and/or garbage input here producing something that + // is usable from a machine perspective. + + if (!isLegalIdentifierInput$1(yyvstack[yysp])) { + let with_value_msg = ' (with optional value assignment)'; + + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1` + yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -4085,29 +4124,30 @@ Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); + } + } else { + this.$ = yyvstack[yysp]; } - } else { - this.$ = yyvstack[yysp]; } - break; case 121: /*! Production:: option_name : "*" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-): this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - // validate that this is legal input under the given circumstances, i.e. parser context: - if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { - this.$ = yyvstack[yysp]; - } else { - var with_value_msg = ' (with optional value assignment)'; + { + // validate that this is legal input under the given circumstances, i.e. parser context: + if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME) { + this.$ = yyvstack[yysp]; + } else { + let with_value_msg = ' (with optional value assignment)'; - if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { - with_value_msg = ''; - } + if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { + with_value_msg = ''; + } - yyparser.yyError(rmCommonWS$1` + yyparser.yyError(rmCommonWS$1` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. Entries (names) must look like regular programming language identifiers, with the addition that option names MAY contain @@ -4116,8 +4156,8 @@ Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); + } } - break; case 122: @@ -4149,22 +4189,24 @@ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])} `); + } } - } - this.$ = srcCode; + this.$ = srcCode; + } break; case 126: @@ -4207,25 +4249,27 @@ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2])} `); - } - } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) - // we append those protective double newlines right now, as the calling site - // won't do it for us: + } + } // Since the epilogue is concatenated as-is (see the `epilogue_chunks` rule above) + // we append those protective double newlines right now, as the calling site + // won't do it for us: - this.$ = '\n\n' + srcCode + '\n\n'; + this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4233,9 +4277,9 @@ // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = start_marker ? ' or similar, such as ' + start_marker : ''; - yyparser.yyError(rmCommonWS$1` + { + let start_marker = yyvstack[yysp - 1].trim(); + yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. Erroneous area: @@ -4244,7 +4288,8 @@ Technical error report: ${yyvstack[yysp].errStr} `); - this.$ = ''; + this.$ = ''; + } break; case 133: @@ -4261,17 +4306,18 @@ /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ // default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA): this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) - // check if there is only 1 unvalued options: 'path' - - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; - if (len === 1 && lst[0][1] === true) { - // `path`: - path = lst[0][0]; - } else if (len <= 1) { - yyparser.yyError(rmCommonWS$1` + { + // check if there is only 1 unvalued options: 'path' + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; + + if (len === 1 && lst[0][1] === true) { + // `path`: + path = lst[0][0]; + } else if (len <= 1) { + yyparser.yyError(rmCommonWS$1` You did not specify a legal file path for the '%include' statement, which must have the format: %include file_path @@ -4281,8 +4327,8 @@ Technical error report: ${$error.errStr} `); - } else { - yyparser.yyError(rmCommonWS$1` + } else { + yyparser.yyError(rmCommonWS$1` You did specify too many attributes for the '%include' statement, which must have the format: %include file_path @@ -4292,28 +4338,29 @@ Technical error report: ${$error.errStr} `); - } // **Aside**: And no, we don't support nested '%include'! + } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { - encoding: 'utf-8' - }); - var srcCode = trimActionCode$1(fileContent); + let fileContent = fs__default['default'].readFileSync(path, { + encoding: 'utf-8' + }); + let srcCode = trimActionCode$1(fileContent); - if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + if (srcCode) { + let rv = checkActionBlock$1(srcCode, this._$, yy); - if (rv) { - yyparser.yyError(rmCommonWS$1` + if (rv) { + yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(this._$)} `); + } } - } - this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -7621,19 +7668,21 @@ /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; - var l = scanRegExp(yy_.yytext); + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); - yy_.yytext = yy_.yytext[0]; - } + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - return 35; + return 35; + } case 10: /*! Conditions:: action */ @@ -7737,71 +7786,73 @@ /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - yy.include_command_allowed = false; - this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - - var marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + + let marker = yy_.yytext; // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr + /* @ Start Of File */ + || precedingStr === '\n'; // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - var prevEnd = 0; - var endMarkerIndex; + let remaining = this.lookAhead(); + let prevEnd = 0; + let endMarkerIndex; - for (;;) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + for (;;) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; - } + return 24; + } - break; - } // Allow the start marker to be re-matched by the generated lexer rule regex: + break; + } // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + this.unput(marker); // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + yy_.yytext = marker; // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; - } + if (atSOL) { + return 22; + } - return 25; + return 25; + } case 20: /*! Conditions:: rules macro INITIAL */ @@ -7834,41 +7885,43 @@ /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); - - this.pushState('action'); // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - - var la = this.lookAhead(); - - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser - } + { + yy.depth = 0; + yy.include_command_allowed = true; //console.error('*** ACTION start @ 355:', yy_.yytext); + + this.pushState('action'); // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - return 25; + return 25; + } case 24: /*! Conditions:: rules */ @@ -8025,32 +8078,34 @@ /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); - yy_.yytext = v; - } + { + let m = this.matches; + yy_.yytext = NaN; - return 43; + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + yy_.yytext = v; + } + + return 43; + } case 70: /*! Conditions:: rules macro INITIAL */ @@ -8098,27 +8153,29 @@ /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; - yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = !precedingStr - /* @ Start Of File */ - || precedingStr === '\n'; - this.pushState('action'); // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - - this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + { + yy.depth = 0; + yy.include_command_allowed = true; // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr + /* @ Start Of File */ + || precedingStr === '\n'; + this.pushState('action'); // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + + this.unput(yy_.yytext); // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + + if (atSOL) { + return 22; + } - if (atSOL) { - return 22; + return 25; } - return 25; - case 81: /*! Conditions:: INITIAL rules code */ @@ -8237,49 +8294,55 @@ /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -8292,7 +8355,8 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ @@ -8773,9 +8837,9 @@ } } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: lexer.setupDelimitedActionChunkLexerRegex = function lexer__setupDelimitedActionChunkLexerRegex(marker) { @@ -8783,8 +8847,8 @@ // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let doNotPatch = marker === '{'; + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -8792,7 +8856,7 @@ // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -8802,11 +8866,11 @@ spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; // Must we still locate the rule to patch or have we done + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? // // WARNING: our cache/patch must live beyond the current lexer+parser invocation: @@ -8821,14 +8885,14 @@ // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { spec.__action_chunk_rule_idx = i; @@ -8883,11 +8947,11 @@ }(); parser.lexer = lexer; - var rmCommonWS$1 = helpers.rmCommonWS; - var checkActionBlock$1 = helpers.checkActionBlock; - var mkIdentifier$1 = helpers.mkIdentifier; - var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; - var trimActionCode$1 = helpers.trimActionCode; // see also: + const rmCommonWS$1 = helpers.rmCommonWS; + const checkActionBlock$1 = helpers.checkActionBlock; + const mkIdentifier$1 = helpers.mkIdentifier; + const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; + const trimActionCode$1 = helpers.trimActionCode; // see also: // - https://en.wikipedia.org/wiki/C0_and_C1_control_codes // - https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-escapes-in-regular-expressions // - https://kangax.github.io/compat-table/es6/#test-RegExp_y_and_u_flags @@ -8924,11 +8988,11 @@ // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. - var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; + const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -8938,7 +9002,7 @@ function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -8947,10 +9011,10 @@ } function encodeRegexLiteralStr(s, edge) { - var rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': @@ -8964,7 +9028,7 @@ continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; @@ -8980,7 +9044,7 @@ // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { @@ -9006,7 +9070,7 @@ if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; @@ -9014,7 +9078,7 @@ if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; @@ -9022,7 +9086,7 @@ if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; @@ -9030,7 +9094,7 @@ if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; @@ -9038,7 +9102,7 @@ if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -9053,24 +9117,24 @@ default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; @@ -9105,7 +9169,7 @@ if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; diff --git a/packages/lex-parser/dist/lex-parser-umd.js b/packages/lex-parser/dist/lex-parser-umd.js index 6f4fc2ac8..fdf131ff6 100644 --- a/packages/lex-parser/dist/lex-parser-umd.js +++ b/packages/lex-parser/dist/lex-parser-umd.js @@ -2555,20 +2555,21 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -2578,6 +2579,7 @@ delete yy.options; delete yy.actionInclude; return this.$; + } case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ @@ -2727,6 +2729,7 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -2735,9 +2738,9 @@ break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS$1` You have specified the lexer condition state '${name}' as both @@ -2784,6 +2787,7 @@ break; } } + } break; case 9: @@ -2868,8 +2872,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -2877,6 +2882,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -2907,8 +2913,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -2916,6 +2923,7 @@ type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -2946,9 +2954,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -2960,6 +2969,7 @@ yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -2985,8 +2995,6 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3007,8 +3015,9 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3023,6 +3032,7 @@ ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -3033,11 +3043,13 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -3082,10 +3094,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -3114,6 +3127,7 @@ type: 'imports', body: body }; + } break; case 24: @@ -3147,10 +3161,11 @@ // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -3172,8 +3187,8 @@ `); } - var srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode$1(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%code ${name}' initialization code section does not compile: ${rv} @@ -3189,6 +3204,7 @@ include: srcCode } }; + } break; case 26: @@ -3200,9 +3216,10 @@ // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS$1` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -3216,6 +3233,7 @@ Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -3428,9 +3446,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -3442,6 +3461,7 @@ yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -3465,8 +3485,8 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3477,6 +3497,7 @@ ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -3487,13 +3508,14 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -3523,6 +3545,7 @@ `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -3688,8 +3711,9 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's action code section does not compile: ${rv} @@ -3699,6 +3723,7 @@ `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -3709,7 +3734,8 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1]); // 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. @@ -3727,7 +3753,7 @@ srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -3742,6 +3768,7 @@ } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -3987,9 +4014,10 @@ // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -4017,6 +4045,7 @@ // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -4028,8 +4057,9 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -4044,6 +4074,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -4054,6 +4085,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4108,13 +4140,14 @@ } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp__default['default']('\\w[\\w\\d]*$'); + let re = new XRegExp__default['default']('\\w[\\w\\d]*$'); if (XRegExp__default['default'].match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -4402,10 +4435,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -4416,8 +4451,10 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -4428,6 +4465,7 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS$1` @@ -4438,7 +4476,7 @@ `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -4455,6 +4493,7 @@ } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -4550,7 +4589,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4563,6 +4603,7 @@ Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -4573,6 +4614,7 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier$1(yyvstack[yysp]); @@ -4581,7 +4623,7 @@ // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput$1(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4598,6 +4640,7 @@ } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -4608,11 +4651,12 @@ // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -4626,6 +4670,7 @@ ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -4669,9 +4714,10 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp]); + { + let srcCode = trimActionCode$1(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%%' lexer epilogue code does not compile: ${rv} @@ -4682,6 +4728,7 @@ } } this.$ = srcCode; + } break; case 126: @@ -4733,9 +4780,10 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode$1(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock$1(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS$1` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4749,6 +4797,7 @@ // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -4759,8 +4808,8 @@ // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); yyparser.yyError(rmCommonWS$1` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4771,6 +4820,7 @@ ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -4794,10 +4844,11 @@ // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -4826,11 +4877,11 @@ } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs__default['default'].readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode$1(fileContent); + let srcCode = trimActionCode$1(fileContent); if (srcCode) { - var rv = checkActionBlock$1(srcCode, this._$, yy); + let rv = checkActionBlock$1(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS$1` The source code included from file '${path}' does not compile: ${rv} @@ -4842,6 +4893,7 @@ } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -9991,21 +10043,22 @@ case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - - return 35; case 10: /*! Conditions:: action */ /*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}"|'{QUOTED_STRING_CONTENT}'|`{ES2017_STRING_CONTENT}` */ @@ -10099,55 +10152,55 @@ case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -10155,24 +10208,25 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 20: /*! Conditions:: rules macro INITIAL */ /*! Rule:: -> */ @@ -10200,44 +10254,45 @@ case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; - - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + { + yy.depth = 0; + yy.include_command_allowed = true; - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - - return 25; case 24: /*! Conditions:: rules */ /*! Rule:: %% */ @@ -10362,38 +10417,39 @@ case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - - return 43; case 70: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\. */ @@ -10433,29 +10489,30 @@ case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - - return 25; case 81: /*! Conditions:: INITIAL rules code */ /*! Rule:: %{NAME}([^\r\n]*) */ @@ -10559,49 +10616,56 @@ case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -10615,7 +10679,8 @@ Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } case 104: /*! Conditions:: options */ /*! Rule:: . */ @@ -11192,9 +11257,9 @@ } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -11203,9 +11268,9 @@ // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -11213,7 +11278,7 @@ // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -11223,11 +11288,11 @@ spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -11243,15 +11308,15 @@ // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -11311,11 +11376,11 @@ }(); parser.lexer = lexer; - var rmCommonWS$1 = helpers.rmCommonWS; - var checkActionBlock$1 = helpers.checkActionBlock; - var mkIdentifier$1 = helpers.mkIdentifier; - var isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; - var trimActionCode$1 = helpers.trimActionCode; + const rmCommonWS$1 = helpers.rmCommonWS; + const checkActionBlock$1 = helpers.checkActionBlock; + const mkIdentifier$1 = helpers.mkIdentifier; + const isLegalIdentifierInput$1 = helpers.isLegalIdentifierInput; + const trimActionCode$1 = helpers.trimActionCode; // see also: @@ -11356,11 +11421,11 @@ // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. - var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; + const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11370,7 +11435,7 @@ function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -11379,10 +11444,10 @@ } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -11392,7 +11457,7 @@ rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -11405,7 +11470,7 @@ // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -11427,35 +11492,35 @@ } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -11469,19 +11534,19 @@ default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -11512,7 +11577,7 @@ // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/lex-parser/lex-parser.js b/packages/lex-parser/lex-parser.js index a10a8cdd3..661f2ccc8 100644 --- a/packages/lex-parser/lex-parser.js +++ b/packages/lex-parser/lex-parser.js @@ -1044,20 +1044,21 @@ case 1: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; - for (var key in yyvstack[yysp - 2]) { + for (let key in yyvstack[yysp - 2]) { this.$[key] = yyvstack[yysp - 2][key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { this.$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { this.$.actionInclude = asrc; @@ -1067,6 +1068,7 @@ case 1: delete yy.options; delete yy.actionInclude; return this.$; + } break; case 2: @@ -1217,6 +1219,7 @@ case 8: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) + { this.$ = yyvstack[yysp - 1]; if (yyvstack[yysp]) { switch (yyvstack[yysp].type) { @@ -1225,9 +1228,9 @@ case 8: break; case 'names': - var condition_defs = yyvstack[yysp].names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = yyvstack[yysp].names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in this.$.startConditions && this.$.startConditions[name] !== condition_defs[i][1]) { yyparser.yyError(rmCommonWS` You have specified the lexer condition state '${name}' as both @@ -1274,6 +1277,7 @@ case 8: break; } } + } break; case 9: @@ -1358,8 +1362,9 @@ case 12: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -1367,6 +1372,7 @@ case 12: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 13: @@ -1397,8 +1403,9 @@ case 14: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -1406,6 +1413,7 @@ case 14: type: 'names', names: lst // 'inclusive' conditions have value 0, 'exclusive' conditions have value 1 }; + } break; case 15: @@ -1436,9 +1444,10 @@ case 16: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -1450,6 +1459,7 @@ case 16: yy.actionInclude.push(srcCode); } this.$ = null; + } break; case 17: @@ -1475,8 +1485,6 @@ case 18: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -1497,8 +1505,9 @@ case 19: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -1513,6 +1522,7 @@ case 19: ${yyvstack[yysp].errStr} `); this.$ = null; + } break; case 20: @@ -1523,11 +1533,13 @@ case 20: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var lst = yyvstack[yysp - 1]; - for (var i = 0, len = lst.length; i < len; i++) { + { + let lst = yyvstack[yysp - 1]; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } this.$ = null; + } break; case 21: @@ -1572,10 +1584,11 @@ case 23: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // check if there are two unvalued options: 'name path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var body; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -1604,6 +1617,7 @@ case 23: type: 'imports', body: body }; + } break; case 24: @@ -1637,10 +1651,11 @@ case 25: // END of default action (generated by JISON mode classic/merge :: 6/6,VT,VA,VU,-,LT,LA,-,-) + { // check there's only 1 option which is an identifier - var lst = yyvstack[yysp - 4]; - var len = lst.length; - var name; + let lst = yyvstack[yysp - 4]; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -1662,8 +1677,8 @@ case 25: `); } - var srcCode = trimActionCode(yyvstack[yysp - 2], yyvstack[yysp - 3]); - var rv = checkActionBlock(srcCode, yylstack[yysp - 2], yy); + let srcCode = trimActionCode(yyvstack[yysp - 2], yyvstack[yysp - 3]); + let rv = checkActionBlock(srcCode, yylstack[yysp - 2], yy); if (rv) { yyparser.yyError(rmCommonWS` The '%code ${name}' initialization code section does not compile: ${rv} @@ -1679,6 +1694,7 @@ case 25: include: srcCode } }; + } break; case 26: @@ -1690,9 +1706,10 @@ case 26: // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 2].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + { + let start_marker = yyvstack[yysp - 2].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyparser.yyError(rmCommonWS` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -1706,6 +1723,7 @@ case 26: Technical error report: ${yyvstack[yysp - 1].errStr} `); + } break; case 27: @@ -1918,9 +1936,10 @@ case 41: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -1932,6 +1951,7 @@ case 41: yy.actionInclude.push(srcCode); } this.$ = yyvstack[yysp - 3]; + } break; case 42: @@ -1955,8 +1975,9 @@ case 43: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -1967,6 +1988,7 @@ case 43: ${yyvstack[yysp].errStr} `); this.$ = yyvstack[yysp - 2]; + } break; case 44: @@ -1977,13 +1999,14 @@ case 44: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); + { + let start_marker = yyvstack[yysp - 1].trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS` The '%{...%}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -2013,6 +2036,7 @@ case 44: `); } this.$ = yyvstack[yysp - 2]; + } break; case 45: @@ -2178,8 +2202,9 @@ case 60: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode(yyvstack[yysp - 1], yyvstack[yysp - 2]); - var rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); + { + let srcCode = trimActionCode(yyvstack[yysp - 1], yyvstack[yysp - 2]); + let rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS` The lexer rule's action code section does not compile: ${rv} @@ -2189,6 +2214,7 @@ case 60: `); } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 61: @@ -2199,7 +2225,8 @@ case 61: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode(yyvstack[yysp - 1]); + { + let srcCode = trimActionCode(yyvstack[yysp - 1]); // 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. @@ -2217,7 +2244,7 @@ case 61: srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -2232,6 +2259,7 @@ case 61: } this.$ = [yyvstack[yysp - 3], srcCode]; + } break; case 62: @@ -2477,9 +2505,10 @@ case 73: // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? this.$ = yyvstack[yysp - 2].map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -2507,6 +2536,7 @@ case 73: // '<' '*' '>' // { $$ = ['*']; } + } break; case 74: @@ -2518,8 +2548,9 @@ case 74: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) + { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = yyvstack[yysp - 1].map(function (el) { + let lst = yyvstack[yysp - 1].map(function (el) { return el[0]; }); @@ -2534,6 +2565,7 @@ case 74: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 75: @@ -2544,6 +2576,7 @@ case 75: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // Detect if the regex ends with a pure (Unicode) word; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -2598,13 +2631,14 @@ case 75: } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp('\\w[\\w\\d]*$'); + let re = new XRegExp('\\w[\\w\\d]*$'); if (XRegExp.match(this.$, re)) { this.$ = yyvstack[yysp] + "\\b"; } else { this.$ = yyvstack[yysp]; } } + } break; case 76: @@ -2892,10 +2926,12 @@ case 111: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var src = yyvstack[yysp]; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + { + let src = yyvstack[yysp]; + let s = src.substring(1, src.length - 1); + let edge = src[0]; this.$ = encodeRegexLiteralStr(s, edge); + } break; case 112: @@ -2906,8 +2942,10 @@ case 112: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) - var s = yyvstack[yysp]; + { + let s = yyvstack[yysp]; this.$ = encodeRegexLiteralStr(s); + } break; case 113: @@ -2918,6 +2956,7 @@ case 113: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal behaviour under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS) { yyparser.yyError(rmCommonWS` @@ -2928,7 +2967,7 @@ case 113: `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = yyvstack[yysp - 2].map(function (opt) { + let optlist = yyvstack[yysp - 2].map(function (opt) { return opt[0]; }); optlist.push(yyvstack[yysp][0]); @@ -2945,6 +2984,7 @@ case 113: } this.$ = yyvstack[yysp - 2]; this.$.push(yyvstack[yysp]); + } break; case 114: @@ -3040,7 +3080,8 @@ case 119: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) - var with_value_msg = ' (with optional value assignment)'; + { + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -3053,6 +3094,7 @@ case 119: Technical error report: ${yyvstack[yysp].errStr} `); + } break; case 120: @@ -3063,6 +3105,7 @@ case 120: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) { this.$ = mkIdentifier(yyvstack[yysp]); @@ -3071,7 +3114,7 @@ case 120: // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput(yyvstack[yysp])) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -3088,6 +3131,7 @@ case 120: } else { this.$ = yyvstack[yysp]; } + } break; case 121: @@ -3098,11 +3142,12 @@ case 121: // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) + { // validate that this is legal input under the given circumstances, i.e. parser context: if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { this.$ = yyvstack[yysp]; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -3116,6 +3161,7 @@ case 121: ${yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])} `); } + } break; case 122: @@ -3159,9 +3205,10 @@ case 125: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode(yyvstack[yysp]); + { + let srcCode = trimActionCode(yyvstack[yysp]); if (srcCode) { - var rv = checkActionBlock(srcCode, yylstack[yysp], yy); + let rv = checkActionBlock(srcCode, yylstack[yysp], yy); if (rv) { yyparser.yyError(rmCommonWS` The '%%' lexer epilogue code does not compile: ${rv} @@ -3172,6 +3219,7 @@ case 125: } } this.$ = srcCode; + } break; case 126: @@ -3223,9 +3271,10 @@ case 130: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) - var srcCode = trimActionCode(yyvstack[yysp - 1], yyvstack[yysp - 2]); + { + let srcCode = trimActionCode(yyvstack[yysp - 1], yyvstack[yysp - 2]); if (srcCode) { - var rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); + let rv = checkActionBlock(srcCode, yylstack[yysp - 1], yy); if (rv) { yyparser.yyError(rmCommonWS` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -3239,6 +3288,7 @@ case 130: // we append those protective double newlines right now, as the calling site // won't do it for us: this.$ = '\n\n' + srcCode + '\n\n'; + } break; case 131: @@ -3249,8 +3299,9 @@ case 131: // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) - var start_marker = yyvstack[yysp - 1].trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + { + let start_marker = yyvstack[yysp - 1].trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyparser.yyError(rmCommonWS` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -3261,6 +3312,7 @@ case 131: ${yyvstack[yysp].errStr} `); this.$ = ''; + } break; case 133: @@ -3284,10 +3336,11 @@ case 134: // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,LU,LUbA) + { // check if there is only 1 unvalued options: 'path' - var lst = yyvstack[yysp - 1]; - var len = lst.length; - var path; + let lst = yyvstack[yysp - 1]; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -3316,11 +3369,11 @@ case 134: } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode(fileContent); + let srcCode = trimActionCode(fileContent); if (srcCode) { - var rv = checkActionBlock(srcCode, this._$, yy); + let rv = checkActionBlock(srcCode, this._$, yy); if (rv) { yyparser.yyError(rmCommonWS` The source code included from file '${path}' does not compile: ${rv} @@ -3332,6 +3385,7 @@ case 134: } this.$ = '\n// Included by Jison: ' + path + ':\n\n' + srcCode + '\n\n// End Of Include by Jison: ' + path + '\n\n'; + } break; case 135: @@ -8506,21 +8560,23 @@ var lexer = function() { case 9: /*! Conditions:: action */ /*! Rule:: \/.* */ - yy.include_command_allowed = false; + { + yy.include_command_allowed = false; + let l = scanRegExp(yy_.yytext); - var l = scanRegExp(yy_.yytext); + if (l > 0) { + this.unput(yy_.yytext.substring(l)); + yy_.yytext = yy_.yytext.substring(0, l); + } else { + // assume it's a division operator: + this.unput(yy_.yytext.substring(1)); - if (l > 0) { - this.unput(yy_.yytext.substring(l)); - yy_.yytext = yy_.yytext.substring(0, l); - } else { - // assume it's a division operator: - this.unput(yy_.yytext.substring(1)); + yy_.yytext = yy_.yytext[0]; + } - yy_.yytext = yy_.yytext[0]; + return 35; } - return 35; break; case 10: /*! Conditions:: action */ @@ -8624,55 +8680,55 @@ var lexer = function() { case 19: /*! Conditions:: INITIAL rules code options */ /*! Rule:: [%\{]\{+ */ - yy.depth = 0; - - yy.include_command_allowed = false; - this.pushState('action'); - - // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, - // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yy_.yytext; - - // check whether this `%{` marker was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own, i.e. is not a rule action, %code - // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; - - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - - // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); - - // Early sanity check for better error reporting: - // we'd better make sure that end marker indeed does exist in the - // remainder of the input! When it's not, we'll have the `action` - // lexer state running past its due date as it'll then go and spit - // out a 'too may closing braces' error report at some spot way - // beyond the intended end of the action code chunk. - // - // Writing the wrong end marker is a common user mistake, we can - // easily look ahead and check for it now and report a proper hint - // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - - var prevEnd = 0; - var endMarkerIndex; - - for (; ; ) { - endMarkerIndex = remaining.indexOf(endMarker, prevEnd); - - // check for both simple non-existence *and* non-match due to trailing braces, - // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. - if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { - prevEnd = endMarkerIndex + endMarker.length; - continue; - } + { + yy.depth = 0; + yy.include_command_allowed = false; + this.pushState('action'); + + // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yy_.yytext`, + // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). + let marker = yy_.yytext; + + // check whether this `%{` marker was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own, i.e. is not a rule action, %code + // section, etc... + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; + + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + + // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + + // Early sanity check for better error reporting: + // we'd better make sure that end marker indeed does exist in the + // remainder of the input! When it's not, we'll have the `action` + // lexer state running past its due date as it'll then go and spit + // out a 'too may closing braces' error report at some spot way + // beyond the intended end of the action code chunk. + // + // Writing the wrong end marker is a common user mistake, we can + // easily look ahead and check for it now and report a proper hint + // to cover this failure mode in a more helpful manner. + let remaining = this.lookAhead(); + + let prevEnd = 0; + let endMarkerIndex; + + for (; ; ) { + endMarkerIndex = remaining.indexOf(endMarker, prevEnd); + + // check for both simple non-existence *and* non-match due to trailing braces, + // e.g. in this input: `%{{...%}}}` -- note the 3rd curly closing brace. + if (endMarkerIndex >= 0 && remaining[endMarkerIndex + endMarker.length] === '}') { + prevEnd = endMarkerIndex + endMarker.length; + continue; + } - if (endMarkerIndex < 0) { - yy_.yyerror(rmCommonWS` + if (endMarkerIndex < 0) { + yy_.yyerror(rmCommonWS` Incorrectly terminated action code block. We're expecting the '${endMarker}' end marker to go with the given start marker. Regrettably, it does not exist in the remainder of the input. @@ -8680,24 +8736,26 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 24; + return 24; + } + + break; } - break; - } + // Allow the start marker to be re-matched by the generated lexer rule regex: + this.unput(marker); - // Allow the start marker to be re-matched by the generated lexer rule regex: - this.unput(marker); + // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: + yy_.yytext = marker; - // Now RESET `yy_.yytext` to what it was originally, i.e. un-unput that lexer variable explicitly: - yy_.yytext = marker; + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - return 25; break; case 20: /*! Conditions:: rules macro INITIAL */ @@ -8729,44 +8787,46 @@ var lexer = function() { case 23: /*! Conditions:: rules */ /*! Rule:: {WS}+(?!(?:\{\{|\||%|->|=>|→|{WS}|{BR})) */ - yy.depth = 0; - - yy.include_command_allowed = true; + { + yy.depth = 0; + yy.include_command_allowed = true; - //console.error('*** ACTION start @ 355:', yy_.yytext); - this.pushState('action'); + //console.error('*** ACTION start @ 355:', yy_.yytext); + this.pushState('action'); + + // Do a bit of magic that's useful for the parser when we + // call `trimActionCode()` in there to perform a bit of + // rough initial action code chunk cleanup: + // when we start the action block -- hence *delimit* the + // action block -- with a plain old '{' brace, we can + // throw that one and its counterpart out safely without + // damaging the action code in any way. + // + // In order to be able to detect that, we look ahead + // now and see whether or rule's regex with the fancy + // '/!' postcondition check actually hit a '{', which + // is the only action code block starter we cannot + // detect explicitly using any of the '%{.*?%}' lexer + // rules you've seen further above. + // + // Thanks to this rule's regex, we DO know that the + // first look-ahead character will be a non-whitespace + // character, which would either be an action code block + // delimiter *or* a comment starter. In the latter case + // we just throw up our hands and leave code trimming + // and analysis to the more advanced systems which + // follow after `trimActionCode()` has passed once we + // get to the parser productions which process this + // upcoming action code block. + let la = this.lookAhead(); + + if (la[0] === '{') { + yy_.yytext = '{'; // hint the parser + } - // Do a bit of magic that's useful for the parser when we - // call `trimActionCode()` in there to perform a bit of - // rough initial action code chunk cleanup: - // when we start the action block -- hence *delimit* the - // action block -- with a plain old '{' brace, we can - // throw that one and its counterpart out safely without - // damaging the action code in any way. - // - // In order to be able to detect that, we look ahead - // now and see whether or rule's regex with the fancy - // '/!' postcondition check actually hit a '{', which - // is the only action code block starter we cannot - // detect explicitly using any of the '%{.*?%}' lexer - // rules you've seen further above. - // - // Thanks to this rule's regex, we DO know that the - // first look-ahead character will be a non-whitespace - // character, which would either be an action code block - // delimiter *or* a comment starter. In the latter case - // we just throw up our hands and leave code trimming - // and analysis to the more advanced systems which - // follow after `trimActionCode()` has passed once we - // get to the parser productions which process this - // upcoming action code block. - var la = this.lookAhead(); - - if (la[0] === '{') { - yy_.yytext = '{'; // hint the parser + return 25; } - return 25; break; case 24: /*! Conditions:: rules */ @@ -8910,38 +8970,40 @@ var lexer = function() { case 69: /*! Conditions:: rules macro INITIAL */ /*! Rule:: \\(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) */ - var m = this.matches; - - yy_.yytext = NaN; - - if (m[1]) { - // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); - - yy_.yytext = v; - } else if (m[2]) { - // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; - - yy_.yytext = v; - } else if (m[3]) { - // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); - - yy_.yytext = v; - } else if (m[4]) { - // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); - - yy_.yytext = v; - } else if (m[5]) { - // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + { + let m = this.matches; + yy_.yytext = NaN; + + if (m[1]) { + // [1]: octal char: `\012` --> \x0A + let v = parseInt(m[1], 8); + + yy_.yytext = v; + } else if (m[2]) { + // [2]: CONTROL char: `\cA` --> \u0001 + let v = m[2].charCodeAt(0) - 64; + + yy_.yytext = v; + } else if (m[3]) { + // [3]: hex char: `\x41` --> A + let v = parseInt(m[3], 16); + + yy_.yytext = v; + } else if (m[4]) { + // [4]: unicode/UTS2 char: `\u03c0` --> PI + let v = parseInt(m[4], 16); + + yy_.yytext = v; + } else if (m[5]) { + // [5]: unicode code point: `\u{00003c0}` --> PI + let v = parseInt(m[5], 16); + + yy_.yytext = v; + } - yy_.yytext = v; + return 43; } - return 43; break; case 70: /*! Conditions:: rules macro INITIAL */ @@ -8988,29 +9050,31 @@ var lexer = function() { case 80: /*! Conditions:: INITIAL rules code */ /*! Rule:: %include\b */ - yy.depth = 0; + { + yy.depth = 0; + yy.include_command_allowed = true; - yy.include_command_allowed = true; + // check whether this `%include` command was located at the start of the line: + // if it is, we treat it as a different token to signal the grammar we've + // got an action which stands on its own. + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - // check whether this `%include` command was located at the start of the line: - // if it is, we treat it as a different token to signal the grammar we've - // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; + this.pushState('action'); - var atSOL = !precedingStr /* @ Start Of File */ || precedingStr === '\n'; - this.pushState('action'); + // push the parsed '%include' back into the input-to-parse + // to trigger the `` state to re-parse it + // and issue the desired follow-up token: 'INCLUDE': + this.unput(yy_.yytext); - // push the parsed '%include' back into the input-to-parse - // to trigger the `` state to re-parse it - // and issue the desired follow-up token: 'INCLUDE': - this.unput(yy_.yytext); + // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. + if (atSOL) { + return 22; + } - // and allow the next lexer round to match and execute the suitable lexer rule(s) to parse this incoming action code block. - if (atSOL) { - return 22; + return 25; } - return 25; break; case 81: /*! Conditions:: INITIAL rules code */ @@ -9128,52 +9192,62 @@ var lexer = function() { case 100: /*! Conditions:: * */ /*! Rule:: " */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } + break; case 101: /*! Conditions:: * */ /*! Rule:: ' */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } + break; case 102: /*! Conditions:: * */ /*! Rule:: ` */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 39; + return 39; + } + break; case 103: /*! Conditions:: macro rules */ /*! Rule:: . */ - /* b0rk on bad characters */ - var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); + { + /* b0rk on bad characters */ + let rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS` + yy_.yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -9187,7 +9261,9 @@ var lexer = function() { Erroneous area: ` + this.prettyPrintRange(yy_.yylloc)); - return 2; + return 2; + } + break; case 104: /*! Conditions:: options */ @@ -9767,9 +9843,9 @@ var lexer = function() { } }; - var rmCommonWS = helpers.rmCommonWS; - var dquote = helpers.dquote; - var scanRegExp = helpers.scanRegExp; + const rmCommonWS = helpers.rmCommonWS; + const dquote = helpers.dquote; + const scanRegExp = helpers.scanRegExp; // Calculate the end marker to match and produce a // lexer rule to match when the need arrises: @@ -9778,9 +9854,9 @@ var lexer = function() { // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = marker === '{'; + let doNotPatch = marker === '{'; - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -9788,7 +9864,7 @@ var lexer = function() { // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. @@ -9798,11 +9874,11 @@ var lexer = function() { spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -9818,15 +9894,15 @@ var lexer = function() { // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { @@ -9886,11 +9962,11 @@ var lexer = function() { }(); parser.lexer = lexer; -var rmCommonWS = helpers.rmCommonWS; -var checkActionBlock = helpers.checkActionBlock; -var mkIdentifier = helpers.mkIdentifier; -var isLegalIdentifierInput = helpers.isLegalIdentifierInput; -var trimActionCode = helpers.trimActionCode; +const rmCommonWS = helpers.rmCommonWS; +const checkActionBlock = helpers.checkActionBlock; +const mkIdentifier = helpers.mkIdentifier; +const isLegalIdentifierInput = helpers.isLegalIdentifierInput; +const trimActionCode = helpers.trimActionCode; // see also: @@ -9931,11 +10007,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -9945,7 +10021,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -9954,10 +10030,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -9967,7 +10043,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -9980,7 +10056,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -10002,35 +10078,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -10044,19 +10120,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -10087,7 +10163,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/lex-parser/lex.l b/packages/lex-parser/lex.l index 395e6ef2b..ff5b2f21e 100644 --- a/packages/lex-parser/lex.l +++ b/packages/lex-parser/lex.l @@ -166,7 +166,7 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` "/"/\s return 'ACTION_BODY'; // most probably a `/` divide operator. "/".* yy.include_command_allowed = false; - var l = scanRegExp(yytext); + let l = scanRegExp(yytext); if (l > 0) { this.unput(yytext.substring(l)); yytext = yytext.substring(0, l); @@ -265,20 +265,20 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` // keep matched string in local variable as the `unput()` call at the end will also 'unput' `yytext`, // which for our purposes here is highly undesirable (see trimActionCode() use in the BNF parser spec). - var marker = yytext; + let marker = yytext; // check whether this `%{` marker was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own, i.e. is not a rule action, %code // section, etc... - //var precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); - //var precedingStr = this.matched.substr(-this.match.length - 1, 1); - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + //let precedingStr = this.pastInput(1,2).replace(/[\r\n]/g, '\n'); + //let precedingStr = this.matched.substr(-this.match.length - 1, 1); + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = (!precedingStr /* @ Start Of File */ || precedingStr === '\n'); + let atSOL = (!precedingStr /* @ Start Of File */ || precedingStr === '\n'); // Make sure we've the proper lexer rule regex active for any possible `%{...%}`, `{{...}}` or what have we here? - var endMarker = this.setupDelimitedActionChunkLexerRegex(marker); + let endMarker = this.setupDelimitedActionChunkLexerRegex(marker); // Early sanity check for better error reporting: // we'd better make sure that end marker indeed does exist in the @@ -290,9 +290,9 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` // Writing the wrong end marker is a common user mistake, we can // easily look ahead and check for it now and report a proper hint // to cover this failure mode in a more helpful manner. - var remaining = this.lookAhead(); - var prevEnd = 0; - var endMarkerIndex; + let remaining = this.lookAhead(); + let prevEnd = 0; + let endMarkerIndex; for (;;) { endMarkerIndex = remaining.indexOf(endMarker, prevEnd); // check for both simple non-existence *and* non-match due to trailing braces, @@ -413,7 +413,7 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` // follow after `trimActionCode()` has passed once we // get to the parser productions which process this // upcoming action code block. - var la = this.lookAhead(); + let la = this.lookAhead(); if (la[0] === '{') { yytext = '{'; // hint the parser } @@ -559,31 +559,31 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` return 'REGEX_SPECIAL_CHAR'; "\\"(?:([0-7]{1,3})|c([A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}) %{ - var m = this.matches; + let m = this.matches; yytext = NaN; if (m[1]) { // [1]: octal char: `\012` --> \x0A - var v = parseInt(m[1], 8); + let v = parseInt(m[1], 8); yytext = v; } else if (m[2]) { // [2]: CONTROL char: `\cA` --> \u0001 - var v = m[2].charCodeAt(0) - 64; + let v = m[2].charCodeAt(0) - 64; yytext = v; } else if (m[3]) { // [3]: hex char: `\x41` --> A - var v = parseInt(m[3], 16); + let v = parseInt(m[3], 16); yytext = v; } else if (m[4]) { // [4]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[4], 16); + let v = parseInt(m[4], 16); yytext = v; } else if (m[5]) { // [5]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[5], 16); + let v = parseInt(m[5], 16); yytext = v; } return 'ESCAPED_CHAR'; @@ -613,9 +613,9 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` // check whether this `%include` command was located at the start of the line: // if it is, we treat it as a different token to signal the grammar we've // got an action which stands on its own. - var precedingStr = this.matched[this.matched.length - this.match.length - 1]; + let precedingStr = this.matched[this.matched.length - this.match.length - 1]; - var atSOL = (!precedingStr /* @ Start Of File */ || precedingStr === '\n'); + let atSOL = (!precedingStr /* @ Start Of File */ || precedingStr === '\n'); this.pushState('action'); // push the parsed '%include' back into the input-to-parse @@ -712,7 +712,7 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` ` + this.prettyPrintRange(yylloc)); return 'UNTERMINATED_STRING_ERROR'; -<*>\" var rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); +<*>\" let rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. @@ -720,7 +720,7 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` Erroneous area: ` + this.prettyPrintRange(yylloc)); return 'UNTERMINATED_STRING_ERROR'; -<*>\' var rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); +<*>\' let rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. @@ -728,7 +728,7 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` Erroneous area: ` + this.prettyPrintRange(yylloc)); return 'UNTERMINATED_STRING_ERROR'; -<*>\` var rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); +<*>\` let rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); yyerror(rmCommonWS` unterminated string constant encountered while lexing ${rules}. @@ -739,7 +739,7 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` . /* b0rk on bad characters */ - var rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); + let rules = (this.topState() === 'macro' ? 'macro\'s' : this.topState()); yyerror(rmCommonWS` unsupported lexer input encountered while lexing ${rules} (i.e. jison lex regexes) in ${dquote(this.topState())} state. @@ -780,9 +780,9 @@ ANY_LITERAL_CHAR [^\s\r\n<>\[\](){}.*+?:!=|%\/\\^$,\'\"\` %% -var rmCommonWS = helpers.rmCommonWS; -var dquote = helpers.dquote; -var scanRegExp = helpers.scanRegExp; +const rmCommonWS = helpers.rmCommonWS; +const dquote = helpers.dquote; +const scanRegExp = helpers.scanRegExp; @@ -796,9 +796,9 @@ lexer.setupDelimitedActionChunkLexerRegex = function lexer__setupDelimitedAction // we DO NOT patch the `%{...%}` lexer rule as we will handle `{...}` // elsewhere in the lexer anyway: we cannot use a simple regex like // `/{[^]*?}/` to match an entire action code block after all! - var doNotPatch = (marker === '{'); + let doNotPatch = (marker === '{'); - var action_end_marker = marker.replace(/\{/g, '}'); + let action_end_marker = marker.replace(/\{/g, '}'); if (!doNotPatch) { // Note: this bit comes straight from the lexer kernel! @@ -806,7 +806,7 @@ lexer.setupDelimitedActionChunkLexerRegex = function lexer__setupDelimitedAction // Get us the currently active set of lexer rules. // (This is why we push the 'action' lexer condition state above *before* // we commence and work on the ruleset itself.) - var spec = this.__currentRuleSet__; + let spec = this.__currentRuleSet__; if (!spec) { // Update the ruleset cache as we apparently encountered a state change or just started lexing. // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will @@ -815,11 +815,11 @@ lexer.setupDelimitedActionChunkLexerRegex = function lexer__setupDelimitedAction spec = this.__currentRuleSet__ = this._currentRules(); } - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - var rules = spec.rules; - var i; - var action_chunk_regex; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let rules = spec.rules; + let i; + let action_chunk_regex; // Must we still locate the rule to patch or have we done // that already during a previous encounter? @@ -835,14 +835,14 @@ lexer.setupDelimitedActionChunkLexerRegex = function lexer__setupDelimitedAction // **WARNING**: *(this bit, like so much else in here, comes straight from the lexer kernel)* // // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; - var orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. + let orig_re_str1 = '/^(?:%\\{([^]*?)%\\}(?!\\}))/'; + let orig_re_str2 = '/^(?:%\\{([\\s\\S]*?)%\\}(?!\\}))/'; // the XRegExp 'cross-platform' version of the same. // Note: the arrays are 1-based, while `len` itself is a valid index, // hence the non-standard less-or-equal check in the next loop condition! for (i = 1; i <= len; i++) { - var rule_re = regexes[i]; - var re_str = rule_re.toString(); + let rule_re = regexes[i]; + let re_str = rule_re.toString(); //console.error('test regexes:', {i, len, re1: re_str, match1: rule_re.toString() === orig_re_str1, match1: rule_re.toString() === orig_re_str2}); if (re_str === orig_re_str1 || re_str === orig_re_str2) { spec.__action_chunk_rule_idx = i; diff --git a/packages/lex-parser/lex.y b/packages/lex-parser/lex.y index f80f0b103..4355bef77 100644 --- a/packages/lex-parser/lex.y +++ b/packages/lex-parser/lex.y @@ -40,19 +40,19 @@ lex : init definitions rules_and_epilogue EOF { $$ = $rules_and_epilogue; - for (var key in $definitions) { + for (let key in $definitions) { $$[key] = $definitions[key]; } // if there are any options, add them all, otherwise set options to NULL: // can't check for 'empty object' by `if (yy.options) ...` so we do it this way: - for (key in yy.options) { + for (let key in yy.options) { $$.options = yy.options; break; } if (yy.actionInclude) { - var asrc = yy.actionInclude.join('\n\n'); + let asrc = yy.actionInclude.join('\n\n'); // Only a non-empty action code chunk should actually make it through: if (asrc.trim() !== '') { $$.actionInclude = asrc; @@ -180,9 +180,9 @@ definitions break; case 'names': - var condition_defs = $definition.names; - for (var i = 0, len = condition_defs.length; i < len; i++) { - var name = condition_defs[i][0]; + let condition_defs = $definition.names; + for (let i = 0, len = condition_defs.length; i < len; i++) { + let name = condition_defs[i][0]; if (name in $$.startConditions && $$.startConditions[name] !== condition_defs[i][1]) { yyerror(rmCommonWS` You have specified the lexer condition state '${name}' as both @@ -301,8 +301,8 @@ definition // | start_inclusive_keyword option_list OPTIONS_END { - var lst = $option_list; - for (var i = 0, len = lst.length; i < len; i++) { + let lst = $option_list; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 0; // flag as 'inclusive' } @@ -334,8 +334,8 @@ definition // | start_exclusive_keyword option_list OPTIONS_END { - var lst = $option_list; - for (var i = 0, len = lst.length; i < len; i++) { + let lst = $option_list; + for (let i = 0, len = lst.length; i < len; i++) { lst[i][1] = 1; // flag as 'exclusive' } @@ -374,9 +374,9 @@ definition // | ACTION_START_AT_SOL action ACTION_END { - var srcCode = trimActionCode($action, $ACTION_START_AT_SOL); + let srcCode = trimActionCode($action, $ACTION_START_AT_SOL); if (srcCode) { - var rv = checkActionBlock(srcCode, @action, yy); + let rv = checkActionBlock(srcCode, @action, yy); if (rv) { yyerror(rmCommonWS` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -405,8 +405,6 @@ definition // | ACTION_START_AT_SOL error %{ - var start_marker = $ACTION_START_AT_SOL.trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyerror(rmCommonWS` There's very probably a problem with this '%{...%\}' lexer setup action code section. @@ -427,8 +425,8 @@ definition // | ACTION_START error %{ - var start_marker = $ACTION_START.trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let start_marker = $ACTION_START.trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyerror(rmCommonWS` The '%{...%\}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -451,8 +449,8 @@ definition // | option_keyword option_list OPTIONS_END { - var lst = $option_list; - for (var i = 0, len = lst.length; i < len; i++) { + let lst = $option_list; + for (let i = 0, len = lst.length; i < len; i++) { yy.options[lst[i][0]] = lst[i][1]; } $$ = null; @@ -483,9 +481,9 @@ definition | import_keyword option_list OPTIONS_END { // check if there are two unvalued options: 'name path' - var lst = $option_list; - var len = lst.length; - var body; + let lst = $option_list; + let len = lst.length; + let body; if (len === 2 && lst[0][1] === true && lst[1][1] === true) { // `name path`: body = { @@ -533,9 +531,9 @@ definition | init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END { // check there's only 1 option which is an identifier - var lst = $option_list; - var len = lst.length; - var name; + let lst = $option_list; + let len = lst.length; + let name; if (len === 1 && lst[0][1] === true) { // `name`: name = lst[0][0]; @@ -557,8 +555,8 @@ definition `); } - var srcCode = trimActionCode($action, $ACTION_START); - var rv = checkActionBlock(srcCode, @action, yy); + let srcCode = trimActionCode($action, $ACTION_START); + let rv = checkActionBlock(srcCode, @action, yy); if (rv) { yyerror(rmCommonWS` The '%code ${name}' initialization code section does not compile: ${rv} @@ -577,9 +575,9 @@ definition } | init_code_keyword option_list ACTION_START error OPTIONS_END { - var start_marker = $ACTION_START.trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); - var end_marker_msg = marker_msg.replace(/\{/g, '}'); + let start_marker = $ACTION_START.trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let end_marker_msg = marker_msg.replace(/\{/g, '}'); yyerror(rmCommonWS` The '%code ID %{...%\}' initialization code section must be properly wrapped in block start markers (\`%{\`${marker_msg}) @@ -741,9 +739,9 @@ rules // | rules ACTION_START_AT_SOL action ACTION_END { - var srcCode = trimActionCode($action, $ACTION_START_AT_SOL); + let srcCode = trimActionCode($action, $ACTION_START_AT_SOL); if (srcCode) { - var rv = checkActionBlock(srcCode, @action, yy); + let rv = checkActionBlock(srcCode, @action, yy); if (rv) { yyerror(rmCommonWS` The '%{...%}' lexer setup action code section does not compile: ${rv} @@ -772,8 +770,8 @@ rules // | rules ACTION_START_AT_SOL error %{ - var start_marker = $ACTION_START_AT_SOL.trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let start_marker = $ACTION_START_AT_SOL.trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyerror(rmCommonWS` There's very probably a problem with this '%{...%\}' lexer setup action code section. @@ -794,13 +792,13 @@ rules // | rules ACTION_START error %{ - var start_marker = $ACTION_START.trim(); + let start_marker = $ACTION_START.trim(); // When the start_marker is not an explicit `%{`, `{` or similar, the error // is more probably due to indenting the rule regex, rather than an error // in writing the action code block: console.error("*** error! marker:", start_marker); if (start_marker.indexOf('{') >= 0) { - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyerror(rmCommonWS` The '%{...%\}' lexer setup action code section MUST have its action block start marker (\`%{\`${marker_msg}) positioned @@ -987,8 +985,8 @@ rule_block rule : regex ACTION_START action ACTION_END { - var srcCode = trimActionCode($action, $ACTION_START); - var rv = checkActionBlock(srcCode, @action, yy); + let srcCode = trimActionCode($action, $ACTION_START); + let rv = checkActionBlock(srcCode, @action, yy); if (rv) { yyerror(rmCommonWS` The lexer rule's action code section does not compile: ${rv} @@ -1001,8 +999,8 @@ rule } | regex ACTION_START_AT_SOL action ACTION_END { - var srcCode = trimActionCode($action, $ACTION_START_AT_SOL); - var rv = checkActionBlock(srcCode, @action, yy); + let srcCode = trimActionCode($action, $ACTION_START_AT_SOL); + let rv = checkActionBlock(srcCode, @action, yy); if (rv) { yyerror(rmCommonWS` The lexer rule's action code section does not compile: ${rv} @@ -1015,7 +1013,7 @@ rule } | regex ARROW_ACTION_START action ACTION_END { - var srcCode = trimActionCode($action); + let srcCode = trimActionCode($action); // 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. @@ -1033,7 +1031,7 @@ rule srcCode = 'return (' + srcCode + '\n)'; } - var rv = checkActionBlock(srcCode, @action, yy); + let rv = checkActionBlock(srcCode, @action, yy); if (rv) { yyerror(rmCommonWS` The lexer rule's 'arrow' action code section does not compile: ${rv} @@ -1197,7 +1195,7 @@ start_conditions { // rewrite + accept star '*' as name + check if we allow empty list? $$ = $option_list.map(function (el) { - var name = el[0]; + let name = el[0]; // Validate the given condition state: when it isn't known, print an error message // accordingly: @@ -1229,7 +1227,7 @@ start_conditions | start_conditions_marker option_list error { // rewrite + accept star '*' as name + check if we allow empty list? - var lst = $option_list.map(function (el) { + let lst = $option_list.map(function (el) { return el[0]; }); @@ -1304,7 +1302,7 @@ regex } // a 'keyword' starts with an alphanumeric character, // followed by zero or more alphanumerics or digits: - var re = new XRegExp('\\w[\\w\\d]*$'); + let re = new XRegExp('\\w[\\w\\d]*$'); if (XRegExp.match($$, re)) { $$ = $re + "\\b"; } else { @@ -1450,14 +1448,14 @@ range_regex literal_string : STRING_LIT { - var src = $STRING_LIT; - var s = src.substring(1, src.length - 1); - var edge = src[0]; + let src = $STRING_LIT; + let s = src.substring(1, src.length - 1); + let edge = src[0]; $$ = encodeRegexLiteralStr(s, edge); } | CHARACTER_LIT { - var s = $CHARACTER_LIT; + let s = $CHARACTER_LIT; $$ = encodeRegexLiteralStr(s); } ; @@ -1475,7 +1473,7 @@ option_list `); } if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS) { - var optlist = $option_list.map(function (opt) { + let optlist = $option_list.map(function (opt) { return opt[0]; }); optlist.push($option[0]); @@ -1546,7 +1544,7 @@ option } | DUMMY3 error { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -1573,7 +1571,7 @@ option_name // typos and/or garbage input here producing something that // is usable from a machine perspective. if (!isLegalIdentifierInput($name)) { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -1597,7 +1595,7 @@ option_name if (!(yy.__options_flags__ & OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES) || (yy.__options_flags__ & OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME)) { $$ = $star; } else { - var with_value_msg = ' (with optional value assignment)'; + let with_value_msg = ' (with optional value assignment)'; if (yy.__options_flags__ & OPTION_DOES_NOT_ACCEPT_VALUE) { with_value_msg = ''; } @@ -1628,9 +1626,9 @@ epilogue } | start_epilogue_marker epilogue_chunks { - var srcCode = trimActionCode($epilogue_chunks); + let srcCode = trimActionCode($epilogue_chunks); if (srcCode) { - var rv = checkActionBlock(srcCode, @epilogue_chunks, yy); + let rv = checkActionBlock(srcCode, @epilogue_chunks, yy); if (rv) { yyerror(rmCommonWS` The '%%' lexer epilogue code does not compile: ${rv} @@ -1692,9 +1690,9 @@ epilogue_chunk // : ACTION_START_AT_SOL action ACTION_END { - var srcCode = trimActionCode($action, $ACTION_START_AT_SOL); + let srcCode = trimActionCode($action, $ACTION_START_AT_SOL); if (srcCode) { - var rv = checkActionBlock(srcCode, @action, yy); + let rv = checkActionBlock(srcCode, @action, yy); if (rv) { yyerror(rmCommonWS` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -1715,8 +1713,8 @@ epilogue_chunk // | ACTION_START_AT_SOL error %{ - var start_marker = $ACTION_START_AT_SOL.trim(); - var marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); + let start_marker = $ACTION_START_AT_SOL.trim(); + let marker_msg = (start_marker ? ' or similar, such as ' + start_marker : ''); yyerror(rmCommonWS` There's very probably a problem with this '%{...%\}' lexer setup action code section. @@ -1750,9 +1748,9 @@ include_macro_code : include_keyword option_list OPTIONS_END { // check if there is only 1 unvalued options: 'path' - var lst = $option_list; - var len = lst.length; - var path; + let lst = $option_list; + let len = lst.length; + let path; if (len === 1 && lst[0][1] === true) { // `path`: path = lst[0][0]; @@ -1781,11 +1779,11 @@ include_macro_code } // **Aside**: And no, we don't support nested '%include'! - var fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); + let fileContent = fs.readFileSync(path, { encoding: 'utf-8' }); - var srcCode = trimActionCode(fileContent); + let srcCode = trimActionCode(fileContent); if (srcCode) { - var rv = checkActionBlock(srcCode, @$, yy); + let rv = checkActionBlock(srcCode, @$, yy); if (rv) { yyerror(rmCommonWS` The source code included from file '${path}' does not compile: ${rv} @@ -1815,11 +1813,11 @@ include_macro_code %% -var rmCommonWS = helpers.rmCommonWS; -var checkActionBlock = helpers.checkActionBlock; -var mkIdentifier = helpers.mkIdentifier; -var isLegalIdentifierInput = helpers.isLegalIdentifierInput; -var trimActionCode = helpers.trimActionCode; +const rmCommonWS = helpers.rmCommonWS; +const checkActionBlock = helpers.checkActionBlock; +const mkIdentifier = helpers.mkIdentifier; +const isLegalIdentifierInput = helpers.isLegalIdentifierInput; +const trimActionCode = helpers.trimActionCode; // see also: @@ -1860,11 +1858,11 @@ const codeCvtTable = { // Note about 'b' in the regex below: // when inside a literal string, it's BACKSPACE, otherwise it's // the regex word edge condition `\b`. Here it's BACKSPACE. -var codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; +const codedCharRe = /(?:([sSBwWdDpP])|([*+()${}|[\]\/.^?])|([aberfntv])|([0-7]{1,3})|c([@A-Z])|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4})|u\{([0-9a-fA-F]{1,8})\}|())/g; function encodeCharCode(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -1874,7 +1872,7 @@ function encodeCharCode(v) { function encodeUnicodeCodepoint(v) { if (v < 32) { - var rv = codeCvtTable[v]; + let rv = codeCvtTable[v]; if (rv) return rv; return '\\u' + ('0000' + v.toString(16)).substr(-4); } else { @@ -1883,10 +1881,10 @@ function encodeUnicodeCodepoint(v) { } function encodeRegexLiteralStr(s, edge) { - var rv = ''; + let rv = ''; //console.warn("encodeRegexLiteralStr INPUT:", {s, edge}); - for (var i = 0, l = s.length; i < l; i++) { - var c = s[i]; + for (let i = 0, l = s.length; i < l; i++) { + let c = s[i]; switch (c) { case '\\': i++; @@ -1896,7 +1894,7 @@ function encodeRegexLiteralStr(s, edge) { rv += c; continue; } - var pos = '\'"`'.indexOf(c); + let pos = '\'"`'.indexOf(c); if (pos >= 0) { rv += '\\\\' + c; continue; @@ -1909,7 +1907,7 @@ function encodeRegexLiteralStr(s, edge) { // we 'fake' the RegExp 'y'=sticky feature cross-platform by using 'g' flag instead // plus an empty capture group at the end of the regex: when that one matches, // we know we did not get a hit. - var m = codedCharRe.exec(s); + let m = codedCharRe.exec(s); if (m && m[0]) { if (m[1]) { // [1]: regex operators, which occur in a literal string: `\s` --> \\s @@ -1931,35 +1929,35 @@ function encodeRegexLiteralStr(s, edge) { } if (m[4]) { // [4]: octal char: `\012` --> \x0A - var v = parseInt(m[4], 8); + let v = parseInt(m[4], 8); rv += encodeCharCode(v); i += m[4].length - 1; continue; } if (m[5]) { // [5]: CONTROL char: `\cA` --> \u0001 - var v = m[5].charCodeAt(0) - 64; + let v = m[5].charCodeAt(0) - 64; rv += encodeCharCode(v); i++; continue; } if (m[6]) { // [6]: hex char: `\x41` --> A - var v = parseInt(m[6], 16); + let v = parseInt(m[6], 16); rv += encodeCharCode(v); i += m[6].length; continue; } if (m[7]) { // [7]: unicode/UTS2 char: `\u03c0` --> PI - var v = parseInt(m[7], 16); + let v = parseInt(m[7], 16); rv += encodeCharCode(v); i += m[7].length; continue; } if (m[8]) { // [8]: unicode code point: `\u{00003c0}` --> PI - var v = parseInt(m[8], 16); + let v = parseInt(m[8], 16); rv += encodeUnicodeCodepoint(v); i += m[8].length; continue; @@ -1973,19 +1971,19 @@ function encodeRegexLiteralStr(s, edge) { default: // escape regex operators: - var pos = ".*+?^${}()|[]/\\".indexOf(c); + let pos = ".*+?^${}()|[]/\\".indexOf(c); if (pos >= 0) { rv += '\\' + c; continue; } - var cc = charCvtTable[c]; + let cc = charCvtTable[c]; if (cc) { rv += cc; continue; } - var cc = c.charCodeAt(0); + cc = c.charCodeAt(0); if (cc < 32) { - var rvp = codeCvtTable[v]; + let rvp = codeCvtTable[v]; if (rvp) { rv += rvp; } else { @@ -2016,7 +2014,7 @@ function parseValue(v) { // http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number // Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!) if (v && !isNaN(v)) { - var rv = +v; + let rv = +v; if (isFinite(rv)) { return rv; } diff --git a/packages/lex-parser/tests/specs/output/0014-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/output/0014-test.jisonlex-lex.json5 index 4e5217282..1bf492af3 100644 --- a/packages/lex-parser/tests/specs/output/0014-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/output/0014-test.jisonlex-lex.json5 @@ -117,12 +117,12 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: }} - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0014-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/output/0014-test.jisonlex-ref.json5 index 96c9e3b8d..3f5d42c71 100644 --- a/packages/lex-parser/tests/specs/output/0014-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/output/0014-test.jisonlex-ref.json5 @@ -30,16 +30,16 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: }} - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0015-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/output/0015-test.jisonlex-lex.json5 index 8f3c4656b..f20610dae 100644 --- a/packages/lex-parser/tests/specs/output/0015-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/output/0015-test.jisonlex-lex.json5 @@ -117,12 +117,12 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: %}} - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0015-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/output/0015-test.jisonlex-ref.json5 index 9fd8424e4..e3cf7b936 100644 --- a/packages/lex-parser/tests/specs/output/0015-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/output/0015-test.jisonlex-ref.json5 @@ -30,16 +30,16 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: %}} - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0016-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/output/0016-test.jisonlex-lex.json5 index 45539d6dc..32799db27 100644 --- a/packages/lex-parser/tests/specs/output/0016-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/output/0016-test.jisonlex-lex.json5 @@ -172,12 +172,12 @@ to help jison grok more or less complex action code chunks. ^.....^ 5: 6: - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10045:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10098:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0016-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/output/0016-test.jisonlex-ref.json5 index 1019181b5..0090f940a 100644 --- a/packages/lex-parser/tests/specs/output/0016-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/output/0016-test.jisonlex-ref.json5 @@ -38,16 +38,16 @@ to help jison grok more or less complex action code chunks. ^.....^ 5: 6: - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10045:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10098:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0017-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/output/0017-test.jisonlex-lex.json5 index 794454b78..75df7e5b9 100644 --- a/packages/lex-parser/tests/specs/output/0017-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/output/0017-test.jisonlex-lex.json5 @@ -172,12 +172,12 @@ to help jison grok more or less complex action code chunks. ^...^ 6: 7: - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10045:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10098:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0017-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/output/0017-test.jisonlex-ref.json5 index 3eea96021..6816f7c16 100644 --- a/packages/lex-parser/tests/specs/output/0017-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/output/0017-test.jisonlex-ref.json5 @@ -39,16 +39,16 @@ to help jison grok more or less complex action code chunks. ^...^ 6: 7: - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10045:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10098:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0018-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/output/0018-test.jisonlex-ref.json5 index 88a901ec3..e26323e55 100644 --- a/packages/lex-parser/tests/specs/output/0018-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/output/0018-test.jisonlex-ref.json5 @@ -65,11 +65,11 @@ Parse error on line 5: ^ Expecting end of input, "<", "|", "(", "/", ".", "^", "$", "ACTION_START_AT_SOL", "UNTERMINATED_ACTION_BLOCK", "ACTION_START", "UNKNOWN_DECL", "OPTIONS", "IMPORT", "CODE", "START_INC", "START_EXC", "%%", "SPECIAL_GROUP", "/!", "REGEX_SPECIAL_CHAR", "ESCAPED_CHAR", macro name in '{...}' curly braces, "REGEX_SET_START", "STRING_LIT", "CHARACTER_LIT", "option_keyword", "import_keyword", "init_code_keyword", "start_inclusive_keyword", "start_exclusive_keyword", "start_conditions_marker", "start_epilogue_marker", "scoped_rules_collective", "rule", "start_conditions", "regex", "nonempty_regex_list", "regex_concat", "regex_base", "name_expansion", "any_group_regex", "literal_string", "epilogue", got unexpected "}" - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.yyError (/lex-parser-cjs.js:6656:25) - at Object.parser__PerformAction (/lex-parser-cjs.js:2611:14) - at Object.parse (/lex-parser-cjs.js:7720:24) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.yyError (/lex-parser-cjs.js:6708:25) + at Object.parser__PerformAction (/lex-parser-cjs.js:2613:14) + at Object.parse (/lex-parser-cjs.js:7772:24) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0023-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/output/0023-test.jisonlex-lex.json5 index acf8169ba..f1c633b45 100644 --- a/packages/lex-parser/tests/specs/output/0023-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/output/0023-test.jisonlex-lex.json5 @@ -114,12 +114,12 @@ rules (i.e. jison lex regexes) in "rules" state. ^..........^ 3: return "%{..%}"; 4: }}}}}% - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10609:13) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10673:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0023-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/output/0023-test.jisonlex-ref.json5 index 886a603e5..84ba9603a 100644 --- a/packages/lex-parser/tests/specs/output/0023-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/output/0023-test.jisonlex-ref.json5 @@ -42,16 +42,16 @@ rules (i.e. jison lex regexes) in "rules" state. ^..........^ 3: return "%{..%}"; 4: }}}}}% - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10609:13) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10673:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0029-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/output/0029-test.jisonlex-lex.json5 index eee46a5bf..5544cc13c 100644 --- a/packages/lex-parser/tests/specs/output/0029-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/output/0029-test.jisonlex-lex.json5 @@ -117,12 +117,12 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^^^^^ 3: return "%{..%}"; 4: }}}}}% - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0029-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/output/0029-test.jisonlex-ref.json5 index 459e2f28e..4676b502c 100644 --- a/packages/lex-parser/tests/specs/output/0029-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/output/0029-test.jisonlex-ref.json5 @@ -31,16 +31,16 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^^^^^ 3: return "%{..%}"; 4: }}}}}% - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/output/0031-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/output/0031-test.jisonlex-ref.json5 index 3684c8b73..5611626f8 100644 --- a/packages/lex-parser/tests/specs/output/0031-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/output/0031-test.jisonlex-ref.json5 @@ -46,11 +46,11 @@ Parse error on line 2: --^ Unexpected "ACTION_BODY" - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.yyError (/lex-parser-cjs.js:6656:25) - at Object.parser__PerformAction (/lex-parser-cjs.js:3516:18) - at Object.parse (/lex-parser-cjs.js:7720:24) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.yyError (/lex-parser-cjs.js:6708:25) + at Object.parser__PerformAction (/lex-parser-cjs.js:3538:18) + at Object.parse (/lex-parser-cjs.js:7772:24) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0014-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/reference-output/0014-test.jisonlex-lex.json5 index 4e5217282..1bf492af3 100644 --- a/packages/lex-parser/tests/specs/reference-output/0014-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0014-test.jisonlex-lex.json5 @@ -117,12 +117,12 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: }} - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0014-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/reference-output/0014-test.jisonlex-ref.json5 index 96c9e3b8d..3f5d42c71 100644 --- a/packages/lex-parser/tests/specs/reference-output/0014-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0014-test.jisonlex-ref.json5 @@ -30,16 +30,16 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: }} - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0015-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/reference-output/0015-test.jisonlex-lex.json5 index 8f3c4656b..f20610dae 100644 --- a/packages/lex-parser/tests/specs/reference-output/0015-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0015-test.jisonlex-lex.json5 @@ -117,12 +117,12 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: %}} - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0015-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/reference-output/0015-test.jisonlex-ref.json5 index 9fd8424e4..e3cf7b936 100644 --- a/packages/lex-parser/tests/specs/reference-output/0015-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0015-test.jisonlex-ref.json5 @@ -30,16 +30,16 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: %}} - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0016-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/reference-output/0016-test.jisonlex-lex.json5 index 45539d6dc..32799db27 100644 --- a/packages/lex-parser/tests/specs/reference-output/0016-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0016-test.jisonlex-lex.json5 @@ -172,12 +172,12 @@ to help jison grok more or less complex action code chunks. ^.....^ 5: 6: - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10045:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10098:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0016-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/reference-output/0016-test.jisonlex-ref.json5 index 1019181b5..0090f940a 100644 --- a/packages/lex-parser/tests/specs/reference-output/0016-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0016-test.jisonlex-ref.json5 @@ -38,16 +38,16 @@ to help jison grok more or less complex action code chunks. ^.....^ 5: 6: - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10045:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10098:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0017-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/reference-output/0017-test.jisonlex-lex.json5 index 794454b78..75df7e5b9 100644 --- a/packages/lex-parser/tests/specs/reference-output/0017-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0017-test.jisonlex-lex.json5 @@ -172,12 +172,12 @@ to help jison grok more or less complex action code chunks. ^...^ 6: 7: - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10045:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10098:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0017-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/reference-output/0017-test.jisonlex-ref.json5 index 3eea96021..6816f7c16 100644 --- a/packages/lex-parser/tests/specs/reference-output/0017-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0017-test.jisonlex-ref.json5 @@ -39,16 +39,16 @@ to help jison grok more or less complex action code chunks. ^...^ 6: 7: - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10045:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10098:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0018-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/reference-output/0018-test.jisonlex-ref.json5 index 88a901ec3..e26323e55 100644 --- a/packages/lex-parser/tests/specs/reference-output/0018-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0018-test.jisonlex-ref.json5 @@ -65,11 +65,11 @@ Parse error on line 5: ^ Expecting end of input, "<", "|", "(", "/", ".", "^", "$", "ACTION_START_AT_SOL", "UNTERMINATED_ACTION_BLOCK", "ACTION_START", "UNKNOWN_DECL", "OPTIONS", "IMPORT", "CODE", "START_INC", "START_EXC", "%%", "SPECIAL_GROUP", "/!", "REGEX_SPECIAL_CHAR", "ESCAPED_CHAR", macro name in '{...}' curly braces, "REGEX_SET_START", "STRING_LIT", "CHARACTER_LIT", "option_keyword", "import_keyword", "init_code_keyword", "start_inclusive_keyword", "start_exclusive_keyword", "start_conditions_marker", "start_epilogue_marker", "scoped_rules_collective", "rule", "start_conditions", "regex", "nonempty_regex_list", "regex_concat", "regex_base", "name_expansion", "any_group_regex", "literal_string", "epilogue", got unexpected "}" - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.yyError (/lex-parser-cjs.js:6656:25) - at Object.parser__PerformAction (/lex-parser-cjs.js:2611:14) - at Object.parse (/lex-parser-cjs.js:7720:24) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.yyError (/lex-parser-cjs.js:6708:25) + at Object.parser__PerformAction (/lex-parser-cjs.js:2613:14) + at Object.parse (/lex-parser-cjs.js:7772:24) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0023-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/reference-output/0023-test.jisonlex-lex.json5 index acf8169ba..f1c633b45 100644 --- a/packages/lex-parser/tests/specs/reference-output/0023-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0023-test.jisonlex-lex.json5 @@ -114,12 +114,12 @@ rules (i.e. jison lex regexes) in "rules" state. ^..........^ 3: return "%{..%}"; 4: }}}}}% - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10609:13) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10673:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0023-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/reference-output/0023-test.jisonlex-ref.json5 index 886a603e5..84ba9603a 100644 --- a/packages/lex-parser/tests/specs/reference-output/0023-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0023-test.jisonlex-ref.json5 @@ -42,16 +42,16 @@ rules (i.e. jison lex regexes) in "rules" state. ^..........^ 3: return "%{..%}"; 4: }}}}}% - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10609:13) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10673:15) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0029-test.jisonlex-lex.json5 b/packages/lex-parser/tests/specs/reference-output/0029-test.jisonlex-lex.json5 index eee46a5bf..5544cc13c 100644 --- a/packages/lex-parser/tests/specs/reference-output/0029-test.jisonlex-lex.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0029-test.jisonlex-lex.json5 @@ -117,12 +117,12 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^^^^^ 3: return "%{..%}"; 4: }}}}}% - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8567:13) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9705:18) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8619:13) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_lex [as lex] (/lex-parser-cjs.js:9757:18) at Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0029-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/reference-output/0029-test.jisonlex-ref.json5 index 459e2f28e..4676b502c 100644 --- a/packages/lex-parser/tests/specs/reference-output/0029-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0029-test.jisonlex-ref.json5 @@ -31,16 +31,16 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^^^^^ 3: return "%{..%}"; 4: }}}}}% - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8561:44) - at Object.yyError [as yyerror] (/lex-parser-cjs.js:8592:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10155:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9497:38) - at Object.lexer_next [as next] (/lex-parser-cjs.js:9620:28) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9767:18) - at fastLex (/lex-parser-cjs.js:7061:27) - at Object.parse (/lex-parser-cjs.js:7235:30) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.lexer_parseError [as parseError] (/lex-parser-cjs.js:8613:44) + at Object.yyError [as yyerror] (/lex-parser-cjs.js:8644:19) + at Object.lexer__performAction [as performAction] (/lex-parser-cjs.js:10208:19) + at Object.lexer_test_match [as test_match] (/lex-parser-cjs.js:9549:38) + at Object.lexer_next [as next] (/lex-parser-cjs.js:9672:28) + at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs.js:9819:18) + at fastLex (/lex-parser-cjs.js:7113:27) + at Object.parse (/lex-parser-cjs.js:7287:30) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) diff --git a/packages/lex-parser/tests/specs/reference-output/0031-test.jisonlex-ref.json5 b/packages/lex-parser/tests/specs/reference-output/0031-test.jisonlex-ref.json5 index 3684c8b73..5611626f8 100644 --- a/packages/lex-parser/tests/specs/reference-output/0031-test.jisonlex-ref.json5 +++ b/packages/lex-parser/tests/specs/reference-output/0031-test.jisonlex-ref.json5 @@ -46,11 +46,11 @@ Parse error on line 2: --^ Unexpected "ACTION_BODY" - at Object.parseError (/lex-parser-cjs.js:6473:15) - at Object.yyError (/lex-parser-cjs.js:6656:25) - at Object.parser__PerformAction (/lex-parser-cjs.js:3516:18) - at Object.parse (/lex-parser-cjs.js:7720:24) - at Object.yyparse [as parse] (/lex-parser-cjs.js:11557:25) + at Object.parseError (/lex-parser-cjs.js:6525:15) + at Object.yyError (/lex-parser-cjs.js:6708:25) + at Object.parser__PerformAction (/lex-parser-cjs.js:3538:18) + at Object.parse (/lex-parser-cjs.js:7772:24) + at Object.yyparse [as parse] (/lex-parser-cjs.js:11622:25) at Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5)